public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers/scsi: Check NULL for kmalloc() return
@ 2009-08-07 18:39 Davidlohr Bueso A.
  2009-08-07 18:54 ` Julia Lawall
  2009-08-07 19:54 ` James Bottomley
  0 siblings, 2 replies; 8+ messages in thread
From: Davidlohr Bueso A. @ 2009-08-07 18:39 UTC (permalink / raw)
  To: linux-scsi, kernel-janitors

Verify that ch->dt is not NULL before using it:
ch-dt[elem] = value;

Signed-off-by: Davidlohr Bueso

---
 drivers/scsi/ch.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index 7b1633a..96cbd20 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -353,6 +353,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)
+               return -ENOMEM;
+
        for (elem = 0; elem < ch->counts[CHET_DT]; elem++) {
                id  = -1;
                lun = 0;

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-08-07 20:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-07 18:39 [PATCH] drivers/scsi: Check NULL for kmalloc() return Davidlohr Bueso A.
2009-08-07 18:54 ` Julia Lawall
2009-08-07 19:44   ` Davidlohr Bueso A.
2009-08-07 19:56     ` Julia Lawall
2009-08-07 20:17       ` Davidlohr Bueso A.
2009-08-07 20:33         ` Hannes Eder
2009-08-07 20:42           ` Davidlohr Bueso A.
2009-08-07 19:54 ` James Bottomley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox