mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yang Bai <hamo.by@gmail.com>
To: JBottomley@parallels.com
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Yang Bai <hamo.by@gmail.com>
Subject: [PATCH] scsi: if sd card is removed, do not revalidate it
Date: Tue, 14 Feb 2012 12:10:54 +0800	[thread overview]
Message-ID: <1329192654-11284-1-git-send-email-hamo.by@gmail.com> (raw)

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


             reply	other threads:[~2012-02-14  4:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-14  4:10 Yang Bai [this message]
2012-02-14  4:13 ` Yang Bai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1329192654-11284-1-git-send-email-hamo.by@gmail.com \
    --to=hamo.by@gmail.com \
    --cc=JBottomley@parallels.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®