Skip to contentSkip to conversation

qla4xxx: check the return value of dma_alloc_coherent()

PATCH In review Maurizio Lombardi 2 participants 2 messages Jul 28, 2014 – Jul 30, 2014

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

PATCH 1/1 qla4xxx: check the return value of dma_alloc_coherent()

the qla4xxx_alloc_fw_dump() calls dma_alloc_coherent() but does not check its return value.

---
 drivers/scsi/qla4xxx/ql4_init.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/scsi/qla4xxx/ql4_init.c +6 -0
index 6f12f85..4180d6d 100644
@@ -334,6 +334,12 @@ void qla4xxx_alloc_fw_dump(struct scsi_qla_host *ha)
 	/* Allocate memory for saving the template */
 	md_tmp = dma_alloc_coherent(&ha->pdev->dev, ha->fw_dump_tmplt_size,
 				    &md_tmp_dma, GFP_KERNEL);
+	if (!md_tmp) {
+		ql4_printk(KERN_INFO, ha,
+			   "scsi%ld: Failed to allocate DMA memory\n",
+			   ha->host_no);
+		return;
+	}
 
 	/* Request template */
 	status =  qla4xxx_get_minidump_template(ha, md_tmp_dma);
Signature · 1 line
Maurizio Lombardi
Acked-by on v1 1/1
#1 lore raw

-----Original Message-----
From: Maurizio Lombardi [mailto:[email protected]]
Sent: Monday, July 28, 2014 6:25 PM
To: Vikas Chaudhary
Cc: Dept-Eng iSCSI Driver; linux-scsi; [email protected]; [email protected]
Subject: [PATCH] qla4xxx: check the return value of dma_alloc_coherent()

the qla4xxx_alloc_fw_dump() calls dma_alloc_coherent() but does not check its return value.

---
 drivers/scsi/qla4xxx/ql4_init.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/scsi/qla4xxx/ql4_init.c +6 -0
index 6f12f85..4180d6d 100644
@@ -334,6 +334,12 @@ void qla4xxx_alloc_fw_dump(struct scsi_qla_host *ha)
 	/* Allocate memory for saving the template */
 	md_tmp = dma_alloc_coherent(&ha->pdev->dev, ha->fw_dump_tmplt_size,
 				    &md_tmp_dma, GFP_KERNEL);
+	if (!md_tmp) {
+		ql4_printk(KERN_INFO, ha,
+			   "scsi%ld: Failed to allocate DMA memory\n",
+			   ha->host_no);
+		return;
+	}
 
 	/* Request template */
 	status =  qla4xxx_get_minidump_template(ha, md_tmp_dma);
Signature · 1 line
Maurizio Lombardi