From: Jeff Woods <kazrak+kernel@cesmail.net>
To: Andries Brouwer <aebr@win.tue.nl>
Cc: linux-scsi@vger.kernel.org,
linux-usb-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] oops in sd_shutdown
Date: Mon, 11 Aug 2003 18:13:50 -0700 [thread overview]
Message-ID: <5.2.1.1.0.20030811180413.01a67dc0@no.incoming.mail> (raw)
In-Reply-To: <20030812002844.B1353@pclin040.win.tue.nl>
At +0200 12:28 AM 8/12/2003, Andries Brouwer wrote (in part):
>The obvious patch (with whitespace damage)
>
>diff -u --recursive --new-file -X /linux/dontdiff a/drivers/scsi/sd.c
>b/drivers/scsi/sd.c
>--- a/drivers/scsi/sd.c Mon Jul 28 05:39:31 2003
>+++ b/drivers/scsi/sd.c Tue Aug 12 01:24:51 2003
>@@ -1351,10 +1351,14 @@
> static void sd_shutdown(struct device *dev)
> {
> struct scsi_device *sdp = to_scsi_device(dev);
>- struct scsi_disk *sdkp = dev_get_drvdata(dev);
>+ struct scsi_disk *sdkp;
> struct scsi_request *sreq;
> int retries, res;
>
>+ sdkp = dev_get_drvdata(dev);
>+ if (!sdkp)
>+ return; /* this can happen */
>+
> if (!sdp->online || !sdkp->WCE)
> return;
Looking only at the above code snippet, I'd suggest something more like:
~~~~~~~~~~~~~~~~~~
diff -u --recursive --new-file -X /linux/dontdiff a/drivers/scsi/sd.c
b/drivers/scsi/sd.c
--- a/drivers/scsi/sd.c Mon Jul 28 05:39:31 2003
+++ b/drivers/scsi/sd.c Tue Aug 12 01:24:51 2003
@@ -1351,10 +1351,14 @@
static void sd_shutdown(struct device *dev)
{
struct scsi_device *sdp = to_scsi_device(dev);
struct scsi_disk *sdkp = dev_get_drvdata(dev);
struct scsi_request *sreq;
int retries, res;
- if (!sdp->online || !sdkp->WCE)
+ if (!sdp || !sdp->online || !sdkp || !sdkp->WCE)
return;
~~~~~~~~~~~~~~~~~~
If sdp can *never* be NULL *and* this is a performance-critical code-path
then perhaps it makes sense to leave off the "!sdp || " which I added to
the logic, but it seems a very small cost to pay for the insurance checking
in sd_shutdown().
--
Jeff Woods <kazrak+kernel@cesmail.net>
next prev parent reply other threads:[~2003-08-12 1:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Pine.LNX.4.53.0308111426570.16008@thevillage.soulcatcher>
2003-08-11 22:28 ` Andries Brouwer
2003-08-12 1:13 ` Jeff Woods [this message]
2003-08-12 2:49 ` Andries Brouwer
2003-08-12 6:35 ` Jeff Woods
2003-08-12 21:36 ` [linux-usb-devel] " Greg KH
2003-08-12 6:53 ` Christoph Hellwig
2003-08-12 8:51 ` Andries Brouwer
2003-08-12 21:35 ` [linux-usb-devel] " Greg KH
2003-08-13 0:24 ` Mike Anderson
2003-08-13 10:46 ` Andries Brouwer
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=5.2.1.1.0.20030811180413.01a67dc0@no.incoming.mail \
--to=kazrak+kernel@cesmail.net \
--cc=aebr@win.tue.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linux-usb-devel@lists.sourceforge.net \
/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®