From: Alan Stern Date: Tue, 26 Jul 2005 14:30:40 +0000 (-0400) Subject: [SCSI] Fix module removal/device add race X-Git-Tag: firefly_0821_release~41159^2~3 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b70d37bf61f278f9d9adf17c52af6b2d0ae7800c;p=firefly-linux-kernel-4.4.55.git [SCSI] Fix module removal/device add race This patch (as546) fixes an oops-causing failure to check the return code from scsi_device_get. The call can return an error if the LLD is being unloaded from memory. Signed-off-by: Alan Stern Signed-off-by: James Bottomley --- diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 76577fae60fa..a0975c78b968 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -870,8 +870,12 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget, out_free_sdev: if (res == SCSI_SCAN_LUN_PRESENT) { if (sdevp) { - scsi_device_get(sdev); - *sdevp = sdev; + if (scsi_device_get(sdev) == 0) { + *sdevp = sdev; + } else { + __scsi_remove_device(sdev); + res = SCSI_SCAN_NO_RESPONSE; + } } } else { if (sdev->host->hostt->slave_destroy)