diff options
| author | Hannes Reinecke <hare@suse.de> | 2016-04-26 08:06:58 +0200 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-07-04 11:51:35 +0200 |
| commit | 2b338459a70cfec522299e3c5e0e59f60dbbd9be (patch) | |
| tree | 5fc10a5ac58df130a5fa76e7ca723b0534f2b972 /drivers/scsi | |
| parent | d65812f74faca251864d21c513b09a3f9ab92dad (diff) | |
sd: get disk reference in sd_check_events()
commit eb72d0bb84eee5d0dc3044fd17b75e7101dabb57 upstream.
sd_check_events() is called asynchronously, and might race
with device removal. So always take a disk reference when
processing the event to avoid the device being removed while
the event is processed.
Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Jinpu Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Willy Tarreau <w@1wt.eu>
Diffstat (limited to 'drivers/scsi')
| -rw-r--r-- | drivers/scsi/sd.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 460132e0c..b97268942 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1354,11 +1354,15 @@ static int media_not_present(struct scsi_disk *sdkp, **/ static unsigned int sd_check_events(struct gendisk *disk, unsigned int clearing) { - struct scsi_disk *sdkp = scsi_disk(disk); - struct scsi_device *sdp = sdkp->device; + struct scsi_disk *sdkp = scsi_disk_get(disk); + struct scsi_device *sdp; struct scsi_sense_hdr *sshdr = NULL; int retval; + if (!sdkp) + return 0; + + sdp = sdkp->device; SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_check_events\n")); /* @@ -1425,6 +1429,7 @@ out: //add for sdcard hotplug end #endif sdp->changed = 0; + scsi_disk_put(sdkp); return retval; } |
