From: Matthew Dobson Date: Tue, 22 Nov 2005 05:32:29 +0000 (-0800) Subject: [PATCH] Fix a bug in scsi_get_command X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=79e448bf2d71d52d28c99be4faff9cc51928f90b;p=GitHub%2FLineageOS%2Fandroid_kernel_samsung_universal7580.git [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 Cc: James Bottomley Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 0be60bba58d..180676d7115 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -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);