From: Martin K. Petersen Date: Fri, 22 Jul 2011 15:59:17 +0000 (-0700) Subject: SCSI: Fix oops dereferencing queue X-Git-Tag: v2.6.39-400.9.0~919 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2933d0d053ae08b85f548948811dae0ab3d452b8;p=users%2Fjedix%2Flinux-maple.git SCSI: Fix oops dereferencing queue Commit 86cbfb5607d4b81b1a993ff689bbd2addd5d3a9b introduced a regression where requests could be queued after a device had disappeared. Subsequent commits have attempted to fix some but not all of these issues. Since there appears to be ongoing discussion about the proper way to fix this we'll partially revert the upstream commit. Signed-off-by: Martin K. Petersen Signed-off-by: guru.anbalagane --- diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index e0bd3f790fca1..1d7b605824e8c 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -322,9 +322,14 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work) kfree(evt); } - blk_put_queue(sdev->request_queue); - /* NULL queue means the device can't be used */ - sdev->request_queue = NULL; + if (sdev->request_queue) { + sdev->request_queue->queuedata = NULL; + /* user context needed to free queue */ + scsi_free_queue(sdev->request_queue); + blk_put_queue(sdev->request_queue); + /* NULL queue means the device can't be used */ + sdev->request_queue = NULL; + } scsi_target_reap(scsi_target(sdev)); @@ -936,8 +941,6 @@ void __scsi_remove_device(struct scsi_device *sdev) /* cause the request function to reject all I/O requests */ sdev->request_queue->queuedata = NULL; - /* Freeing the queue signals to block that we're done */ - scsi_free_queue(sdev->request_queue); put_device(dev); }