[PATCH] Fix a bug in scsi_get_command

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>

authored by Matthew Dobson and committed by Linus Torvalds 79e448bf e738cf6d

+1 -1
+1 -1
drivers/scsi/scsi.c
··· 265 spin_lock_irqsave(&dev->list_lock, flags); 266 list_add_tail(&cmd->list, &dev->cmd_list); 267 spin_unlock_irqrestore(&dev->list_lock, flags); 268 } else 269 put_device(&dev->sdev_gendev); 270 271 - cmd->jiffies_at_alloc = jiffies; 272 return cmd; 273 } 274 EXPORT_SYMBOL(scsi_get_command);
··· 265 spin_lock_irqsave(&dev->list_lock, flags); 266 list_add_tail(&cmd->list, &dev->cmd_list); 267 spin_unlock_irqrestore(&dev->list_lock, flags); 268 + cmd->jiffies_at_alloc = jiffies; 269 } else 270 put_device(&dev->sdev_gendev); 271 272 return cmd; 273 } 274 EXPORT_SYMBOL(scsi_get_command);