Re: [PATCH] scsi: if sd card is removed, do not revalidate it

From: Yang Bai
Date: Mon Feb 13 2012 - 23:13:36 EST


On Tue, Feb 14, 2012 at 12:10 PM, Yang Bai <hamo.by@xxxxxxxxx> wrote:
> 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@xxxxxxxxx>
> ---
> Â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
>

Is this the right way to solve this problem? Or should we add
a lock to this struct to protect it?

--
  """
  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-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/