From: "Simon Holm Thøgersen" <odie@cs.aau.dk>
To: Jens Axboe <jens.axboe@oracle.com>
Cc: Micah Gruber <micah.gruber@gmail.com>,
linux-kernel@vger.kernel.org,
linux-usb-devel@lists.sourceforge.net, gregkh@suse.de
Subject: [PATCH] Remove pointless NULL pointer check in drivers/usb/storage/shuttle_usbat.c.
Date: Fri, 07 Sep 2007 00:33:29 +0200 [thread overview]
Message-ID: <1189118009.19079.22.camel@odie.local> (raw)
In-Reply-To: <20070904210630.GD4117@kernel.dk>
tir, 04 09 2007 kl. 23:06 +0200, skrev Jens Axboe:
> On Tue, Sep 04 2007, Simon Holm Thøgersen wrote:
> > tir, 04 09 2007 kl. 13:06 +0200, skrev Jens Axboe:
> > > On Tue, Sep 04 2007, Micah Gruber wrote:
> > > > This patch fixes a potential null dereference bug where we dereference us before a null check. This patch simply moves the dereferencing after the null check.
> > > >
> > > > Signed-off-by: Micah Gruber <micah.gruber@gmail.com>
> > >
> > > Be careful with stuff like that, if you actually look at the code, a us
> > > == NULL doesn't seem to be possible (or usbat_flash_transport() would
> > > have oopsed before).
> > >
> > If that is true, then
> > if (!us)
> > return USB_STOR_TRANSPORT_ERROR;
> > is utterly pointless.
>
> Well that was the point I was trying to make, that test and return
> should be deleted instead.
>
I guess we agree that we want the following then.
If us would ever be NULL, the function would have oopsed already before
the check.
Signed-off-by: Simon Holm Thøgersen <odie@cs.aau.dk>
---
--- a/drivers/usb/storage/shuttle_usbat.c
+++ b/drivers/usb/storage/shuttle_usbat.c
@@ -190,9 +190,6 @@ static int usbat_check_status(struct us_data *us)
unsigned char *reply = us->iobuf;
int rc;
- if (!us)
- return USB_STOR_TRANSPORT_ERROR;
-
rc = usbat_get_status(us, reply);
if (rc != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_FAILED;
next prev parent reply other threads:[~2007-09-06 22:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-04 8:25 [PATCH] Fix a potential NULL pointer dereference in usbat_check_status() " Micah Gruber
2007-09-04 11:06 ` Jens Axboe
2007-09-04 19:57 ` Simon Holm Thøgersen
2007-09-04 20:58 ` [linux-usb-devel] " Alan Stern
2007-09-04 21:06 ` Jens Axboe
2007-09-06 22:33 ` Simon Holm Thøgersen [this message]
2007-09-10 16:33 ` [PATCH] Remove pointless NULL pointer check " Jens Axboe
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=1189118009.19079.22.camel@odie.local \
--to=odie@cs.aau.dk \
--cc=gregkh@suse.de \
--cc=jens.axboe@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb-devel@lists.sourceforge.net \
--cc=micah.gruber@gmail.com \
/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®