* [PATCH] scsi: check kmalloc() return value.
@ 2007-03-09 7:16 Amit Choudhary
0 siblings, 0 replies; only message in thread
From: Amit Choudhary @ 2007-03-09 7:16 UTC (permalink / raw)
To: Linux Kernel
Description: Check the return value of kmalloc() in function ch_readconfig(), in file drivers/scsi/ch.c.
Signed-off-by: Amit Choudhary <amit2030@gmail.com>
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index f6caa43..fcd635b 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -324,7 +324,7 @@ ch_readconfig(scsi_changer *ch)
if (!buffer)
return -ENOMEM;
memset(buffer,0,512);
-
+
memset(cmd,0,sizeof(cmd));
cmd[0] = MODE_SENSE;
cmd[1] = ch->device->lun << 5;
@@ -367,7 +367,7 @@ ch_readconfig(scsi_changer *ch)
} else {
vprintk("reading element address assigment page failed!\n");
}
-
+
/* vendor specific element types */
for (i = 0; i < 4; i++) {
if (0 == vendor_counts[i])
@@ -384,6 +384,10 @@ ch_readconfig(scsi_changer *ch)
/* look up the devices of the data transfer elements */
ch->dt = kmalloc(ch->counts[CHET_DT]*sizeof(struct scsi_device),
GFP_KERNEL);
+ if (!ch->dt) {
+ kfree(buffer);
+ return -ENOMEM;
+ }
for (elem = 0; elem < ch->counts[CHET_DT]; elem++) {
id = -1;
lun = 0;
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2007-03-09 7:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-09 7:16 [PATCH] scsi: check kmalloc() return value Amit Choudhary
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.