From: Christoph Hellwig Date: Tue, 15 Apr 2014 10:24:56 +0000 (+0200) Subject: [SCSI] don't reference freed command in scsi_prep_return X-Git-Tag: v3.15-rc3~13^2~4 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=68c03d9193f55dad93036f439b94912c5003a173;p=linux.git [SCSI] don't reference freed command in scsi_prep_return Patch commit 0479633686d370303e3430256ace4bd5f7f138dc Author: Christoph Hellwig Date: Thu Feb 20 14:20:55 2014 -0800 [SCSI] do not manipulate device reference counts in scsi_get/put_command Introduced a use after free:I in the kill case of scsi_prep_return we have to release our device reference, but we do this trying to reference the just freed command. Use the local sdev pointer instead. Fixes: 0479633686d370303e3430256ace4bd5f7f138dc Reported-by: Joe Lawrence Signed-off-by: Christoph Hellwig Signed-off-by: James Bottomley --- diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 54eff6a79fb8..7fa54fe51f63 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1274,7 +1274,7 @@ int scsi_prep_return(struct request_queue *q, struct request *req, int ret) struct scsi_cmnd *cmd = req->special; scsi_release_buffers(cmd); scsi_put_command(cmd); - put_device(&cmd->device->sdev_gendev); + put_device(&sdev->sdev_gendev); req->special = NULL; } break;