Skip to contentSkip to conversation

zfcp: test kmalloc failure in scsi_get_vpd_page()

PATCH In review [email protected] 1 participant 1 message Nov 17, 2009 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 11/18 zfcp: test kmalloc failure in scsi_get_vpd_page()

From: Roel Kluin <[email protected]>

kmalloc() may fail, so test whether it succeeded.

Cc James Bottomley <[email protected]>
Cc Wei Yongjun <[email protected]>
Cc Mike Christie <[email protected]>
Cc Boaz Harrosh <[email protected]>

---

 drivers/scsi/scsi.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/scsi/scsi.c renamed from drivers/scsi/scsi.c~zfcp-test-kmalloc-failure-in-scsi_get_vpd_page +2 -0
diff -puN drivers/scsi/scsi.c~zfcp-test-kmalloc-failure-in-scsi_get_vpd_page drivers/scsi/scsi.c
@@ -1066,6 +1066,8 @@ unsigned char *scsi_get_vpd_page(struct 
 
 	kfree(buf);
 	buf = kmalloc(len, GFP_KERNEL);
+	if (!buf)
+		return NULL;
 	result = scsi_vpd_inquiry(sdev, buf, page, len);
 	if (result)
 		goto fail;

_