summaryrefslogtreecommitdiff
path: root/drivers/misc/habanalabs/common/firmware_if.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2020-08-26 20:50:50 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2020-08-26 20:50:50 +0300
commit27563ab6ef75abc64b7da2c7a321b7edd89dfcf7 (patch)
tree55b9cabd699deb690b4a8ac3f43ea5b00b53c75a /drivers/misc/habanalabs/common/firmware_if.c
parent51c4518ab77c6d3e917675891a9a529daabfaef1 (diff)
parent9c97cecab0d49e40460d9b5230ab4bf036f59491 (diff)
downloadlinux-27563ab6ef75abc64b7da2c7a321b7edd89dfcf7.tar.xz
Merge tag 'char-misc-5.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver fixes from Greg KH: "Here are some small char and misc and other driver subsystem fixes for 5.9-rc3. The majority of these are tiny habanalabs driver fixes, but also in here are: - speakup build fixes now that it is out of staging and got exposed to more build systems all of a sudden - mei driver fix All of these have been in linux-next for a while with no reported issues" * tag 'char-misc-5.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: habanalabs: correctly report inbound pci region cfg error habanalabs: check correct vmalloc return code habanalabs: validate FW file size habanalabs: fix incorrect check on failed workqueue create habanalabs: set max power according to card type habanalabs: proper handling of alloc size in coresight habanalabs: set clock gating according to mask habanalabs: verify user input in cs_ioctl_signal_wait habanalabs: Fix a loop in gaudi_extract_ecc_info() habanalabs: Fix memory corruption in debugfs habanalabs: validate packet id during CB parse habanalabs: Validate user address before mapping habanalabs: unmap PCI bars upon iATU failure mei: hdcp: fix mei_hdcp_verify_mprime() input parameter speakup: only build serialio when ISA is enabled speakup: Fix wait_for_xmitr for ttyio case
Diffstat (limited to 'drivers/misc/habanalabs/common/firmware_if.c')
-rw-r--r--drivers/misc/habanalabs/common/firmware_if.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/misc/habanalabs/common/firmware_if.c b/drivers/misc/habanalabs/common/firmware_if.c
index f70302cdab1b..f52bc690dfc5 100644
--- a/drivers/misc/habanalabs/common/firmware_if.c
+++ b/drivers/misc/habanalabs/common/firmware_if.c
@@ -13,6 +13,7 @@
#include <linux/io-64-nonatomic-lo-hi.h>
#include <linux/slab.h>
+#define FW_FILE_MAX_SIZE 0x1400000 /* maximum size of 20MB */
/**
* hl_fw_load_fw_to_device() - Load F/W code to device's memory.
*
@@ -48,6 +49,14 @@ int hl_fw_load_fw_to_device(struct hl_device *hdev, const char *fw_name,
dev_dbg(hdev->dev, "%s firmware size == %zu\n", fw_name, fw_size);
+ if (fw_size > FW_FILE_MAX_SIZE) {
+ dev_err(hdev->dev,
+ "FW file size %zu exceeds maximum of %u bytes\n",
+ fw_size, FW_FILE_MAX_SIZE);
+ rc = -EINVAL;
+ goto out;
+ }
+
fw_data = (const u64 *) fw->data;
memcpy_toio(dst, fw_data, fw_size);