Skip to contentSkip to conversation

scsi: qla2xxx: Use array_size() in vmalloc()

PATCH New Michael Estner 1 participant 1 message Sep 29

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: qla2xxx: Use array_size() in vmalloc()

vmalloc() has no 2-factor argument form, so multiplication factors computing its size need to be wrapped in array_size().

This issue was found with the help of Coccinelle and audited and fixed manually.

Addresses-KSPP-ID: https://github.com/KSPP/linux/issues/83

---
 drivers/scsi/qla2xxx/qla_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_init.c +1 -1
index bb0cc71de37b8..b269407d0ef11 100644
@@ -8652,7 +8652,7 @@ qla28xx_load_fw_template(scsi_qla_host_t *vha, uint32_t faddr)
 		ql_dbg(ql_dbg_init, vha, 0x01a5,
 		    "-> fwdt%u template allocate template %#x words...\n",
 		    j, risc_size);
-		fwdt->template = vmalloc(risc_size * sizeof(*dcode));
+		fwdt->template = vmalloc(array_size(risc_size, sizeof(*dcode)));
 		if (!fwdt->template) {
 			ql_log(ql_log_warn, vha, 0x01a6,
 			    "-> fwdt%u failed allocate template.\n", j);
Signature · 1 line
2.34.1