]> err.no Git - linux-2.6/commitdiff
[SCSI] gdth: Allocate sense_buffer to prevent NULL pointer dereference
authorSven Schnelle <svens@bitebene.org>
Mon, 10 Mar 2008 21:50:04 +0000 (22:50 +0100)
committerJames Bottomley <James.Bottomley@HansenPartnership.com>
Sat, 15 Mar 2008 01:31:18 +0000 (20:31 -0500)
Fix NULL pointer dereference during execution of Internal commands,
where gdth only allocates scp, but not scp->sense_buffer. The rest of
the code assumes that sense_buffer is allocated, which leads to a kernel
oops e.g. on reboot (during cache flush).

Signed-off-by: Sven Schnelle <svens@stackframe.org>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
drivers/scsi/gdth.c

index 27ebd336409b6fbd922c17360438a7c0ec79babe..0b2080d335750b0d89157a87f5170226dd14d1ca 100644 (file)
@@ -493,6 +493,12 @@ int __gdth_execute(struct scsi_device *sdev, gdth_cmd_str *gdtcmd, char *cmnd,
     if (!scp)
         return -ENOMEM;
 
+    scp->sense_buffer = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL);
+    if (!scp->sense_buffer) {
+       kfree(scp);
+       return -ENOMEM;
+    }
+
     scp->device = sdev;
     memset(&cmndinfo, 0, sizeof(cmndinfo));
 
@@ -513,6 +519,7 @@ int __gdth_execute(struct scsi_device *sdev, gdth_cmd_str *gdtcmd, char *cmnd,
     rval = cmndinfo.status;
     if (info)
         *info = cmndinfo.info;
+    kfree(scp->sense_buffer);
     kfree(scp);
     return rval;
 }