]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] Fix a bug in scsi_get_command
authorMatthew Dobson <colpatch@us.ibm.com>
Tue, 22 Nov 2005 05:32:29 +0000 (21:32 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Tue, 22 Nov 2005 17:13:44 +0000 (09:13 -0800)
scsi_get_command() attempts to write into a structure that may not have
been successfully allocated.  Move this write inside the if statement that
ensures we won't panic the kernel with a NULL pointer dereference.

Signed-off-by: Matthew Dobson <colpatch@us.ibm.com>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/scsi/scsi.c

index 0be60bba58d320d4c712426bb140606769f791fe..180676d7115a5861007e92dd9f34a85098d4ad59 100644 (file)
@@ -265,10 +265,10 @@ struct scsi_cmnd *scsi_get_command(struct scsi_device *dev, gfp_t gfp_mask)
                spin_lock_irqsave(&dev->list_lock, flags);
                list_add_tail(&cmd->list, &dev->cmd_list);
                spin_unlock_irqrestore(&dev->list_lock, flags);
+               cmd->jiffies_at_alloc = jiffies;
        } else
                put_device(&dev->sdev_gendev);
 
-       cmd->jiffies_at_alloc = jiffies;
        return cmd;
 }                              
 EXPORT_SYMBOL(scsi_get_command);