mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] scsi: if sd card is removed, do not revalidate it
@ 2012-02-14  4:10 Yang Bai
  2012-02-14  4:13 ` Yang Bai
  0 siblings, 1 reply; 2+ messages in thread
From: Yang Bai @ 2012-02-14  4:10 UTC (permalink / raw)
  To: JBottomley; +Cc: linux-scsi, linux-kernel, Yang Bai

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 <hamo.by@gmail.com>
---
 drivers/scsi/sd.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index c691fb5..470339c 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -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);
-- 
1.7.9


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-02-14  4:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-14  4:10 [PATCH] scsi: if sd card is removed, do not revalidate it Yang Bai
2012-02-14  4:13 ` Yang Bai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®