libata: fix NULL sdev dereference race in atapi_qc_complete()
authorTejun Heo <tj@kernel.org>
Mon, 1 Nov 2010 10:39:19 +0000 (11:39 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 9 Dec 2010 21:32:59 +0000 (13:32 -0800)
commitb805734a0ea3e714a53b2aadaf9b90e196f34976
treeea74472bef60b4a4f6c5b67b06f3ffd395cbdada
parente23d50e43c7e971092c8d7ead29e9912e74623e6
libata: fix NULL sdev dereference race in atapi_qc_complete()

commit 2a5f07b5ec098edc69e05fdd2f35d3fbb1235723 upstream.

SCSI commands may be issued between __scsi_add_device() and dev->sdev
assignment, so it's unsafe for ata_qc_complete() to dereference
dev->sdev->locked without checking whether it's NULL or not.  Fix it.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/ata/libata-scsi.c