Skip to content

Commit

Permalink
[SCSI] ch: Check NULL for kmalloc() return
Browse files Browse the repository at this point in the history
Verify that ch->dt is not NULL before using it.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
  • Loading branch information
Davidlohr Bueso A authored and James Bottomley committed Aug 22, 2009
1 parent d688669 commit a2cf8a6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/scsi/ch.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,12 @@ 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;
Expand Down

0 comments on commit a2cf8a6

Please sign in to comment.