Avoid dangling pointer in scsi_requeue_command()
authorBart Van Assche <bvanassche@acm.org>
Fri, 29 Jun 2012 15:34:26 +0000 (15:34 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 2 Aug 2012 13:37:55 +0000 (14:37 +0100)
commit09411e4280933eb335e1f723dc215a5583c3be8f
treeb25cd89a6afb842080448cb93e3b1a42cad1c40c
parent9c63d964e3f093b858a6f06875a68bc4206f71ba
Avoid dangling pointer in scsi_requeue_command()

commit 940f5d47e2f2e1fa00443921a0abf4822335b54d upstream.

When we call scsi_unprep_request() the command associated with the request
gets destroyed and therefore drops its reference on the device.  If this was
the only reference, the device may get released and we end up with a NULL
pointer deref when we call blk_requeue_request.

Reported-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Reviewed-by: Tejun Heo <tj@kernel.org>
[jejb: enhance commend and add commit log for stable]
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/scsi/scsi_lib.c