From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
Fabio Estevam <festevam@gmail.com>,
Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Subject: Re: [PATCH v2] USB: EHCI: fix dereference of ERR_PTR
Date: Fri, 18 Sep 2015 11:18:19 +0530 [thread overview]
Message-ID: <20150918054819.GA31139@sudip-pc> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1509161249450.1993-100000@iolanthe.rowland.org>
On Wed, Sep 16, 2015 at 12:54:03PM -0400, Alan Stern wrote:
> On Wed, 16 Sep 2015, Sudip Mukherjee wrote:
>
> > On error find_tt() returns either a NULL pointer or the error value in
> > ERR_PTR. But we were dereferencing it directly without even checking if
> > find_tt() returned a valid pointer or not.
> >
> > Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> > ---
<snip>
> > @@ -1373,6 +1375,8 @@ static void reserve_release_iso_bandwidth(struct ehci_hcd *ehci,
> > }
> >
> > tt = find_tt(stream->ps.udev);
> > + if (IS_ERR_OR_NULL(tt))
> > + return;
> > if (sign > 0)
> > list_add_tail(&stream->ps.ps_list, &tt->ps_list);
> > else
>
> This patch isn't needed. In both reserve_release_intr_bandwidth() and
> reserve_release_iso_bandwidth() it is known that find_tt() will return
> a valid pointer.
>
> This is because each of those functions is called from only one place.
> For example, reserve_release_intr_bandwidth() is called only at the end
> of qh_schedule(). But near the start of qh_schedule() there is earlier
> call to tt_find(), and there we do test for error pointers. If the
> first call doesn't return an error then the second call won't either.
>
> The same sort of thing happens in reserve_release_iso_bandwidth().
Yes, I should have looked more before sending. Sorry for the noise.
But in those checkes for find_tt() only IS_ERR is checked, shouldn't we
check for IS_ERR_OR_NULL as find_tt() can return NULL also?
regards
sudip
next prev parent reply other threads:[~2015-09-18 5:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-16 14:08 [PATCH] USB: EHCI: fix dereference of ERR_PTR Sudip Mukherjee
2015-09-16 14:16 ` Fabio Estevam
2015-09-16 14:25 ` Sergei Shtylyov
2015-09-16 16:22 ` [PATCH v2] " Sudip Mukherjee
2015-09-16 16:54 ` Alan Stern
2015-09-18 5:48 ` Sudip Mukherjee [this message]
2015-09-18 14:45 ` Alan Stern
2015-09-21 2:48 ` [PATCH] " Lu, Baolu
2015-09-21 4:49 ` Sudip Mukherjee
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=20150918054819.GA31139@sudip-pc \
--to=sudipm.mukherjee@gmail.com \
--cc=festevam@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=sergei.shtylyov@cogentembedded.com \
--cc=stern@rowland.harvard.edu \
/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;
as well as URLs for NNTP newsgroup(s).