scsi: if sd card is removed, do not revalidate it
PATCH 1/1 scsi: if sd card is removed, do not revalidate it
During revalidating, if sd card is removed, scsi_device will be NULL, so we should not revalidate or it will cause a panic.
This problem is report at:
http://comments.gmane.org/gmane.linux.kernel/1250235
Signed-off-by Yang Bai <[email protected]>
--- drivers/scsi/sd.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/sd.c +2 -2
@@ -2370,10 +2370,10 @@ static int sd_revalidate_disk(struct gendisk *disk) "sd_revalidate_disk\n"));/* -* If the device is offline, don't try and read capacity or any +* If the device is removed or offline, don't try and read capacity or any * of the other niceties. */ -if (!scsi_device_online (sdp)) +if (!sdp || !scsi_device_online (sdp)) goto out; buffer =kmalloc (SD_BUF_SIZE ,GFP_KERNEL );
Signature · 1 line
1.7.9
Quoted 29 lines · Yang Bai
During revalidating, if sd card is removed,
scsi_devicewill be NULL, so we should not revalidate or it will cause a panic.
This problem is report at:
http://comments.gmane.org/gmane.linux.kernel/1250235Signed-off-by Yang Bai <[email protected]>---
drivers/scsi/sd.c | 4 ++--1 files changed, 2 insertions(+), 2 deletions(-)drivers/scsi/sd.c +2
-3@@ -2370,10 +2370,10 @@ static int sd_revalidate_disk(struct gendisk *disk) "sd_revalidate_disk\n")); /* - * If the device is offline, don't try and read capacity or any + * If the device is removed or offline, don't try and read capacity or any * of the other niceties. */ - if (!scsi_device_online(sdp)) + if (!sdp || !scsi_device_online(sdp)) goto out; buffer = kmalloc(SD_BUF_SIZE, GFP_KERNEL); --
Quoted 2 lines
1.7.9
Is this the right way to solve this problem? Or should we add a lock to this struct to protect it?
Signature · 13 lines
""" Keep It Simple,Stupid. """ Chinese Name: 白杨 Nick Name: Hamo Homepage: http://hamobai.com/ GPG KEY ID: 0xA4691A33 Key fingerprint = 09D5 2D78 8E2B 0995 CF8E 4331 33C4 3D24 A469 1A33 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html