Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1227577

Re: [PATCH v2] USB: EHCI: fix dereference of ERR_PTR

From Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2] USB: EHCI: fix dereference of ERR_PTR
Date 2015-09-18 07:50 +0200
Message-ID <q9WIy-1Wn-21@gated-at.bofh.it> (permalink)
References <q9nKR-1iB-69@gated-at.bofh.it> <q9odP-1QO-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] USB: EHCI: fix dereference of ERR_PTR Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-09-16 16:10 +0200
  Re: [PATCH] USB: EHCI: fix dereference of ERR_PTR Fabio Estevam <festevam@gmail.com> - 2015-09-16 16:20 +0200
  Re: [PATCH] USB: EHCI: fix dereference of ERR_PTR Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2015-09-16 16:30 +0200
  [PATCH v2] USB: EHCI: fix dereference of ERR_PTR Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-09-16 18:30 +0200
    Re: [PATCH v2] USB: EHCI: fix dereference of ERR_PTR Alan Stern <stern@rowland.harvard.edu> - 2015-09-16 19:00 +0200
      Re: [PATCH v2] USB: EHCI: fix dereference of ERR_PTR Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-09-18 07:50 +0200
        Re: [PATCH v2] USB: EHCI: fix dereference of ERR_PTR Alan Stern <stern@rowland.harvard.edu> - 2015-09-18 16:50 +0200
  Re: [PATCH] USB: EHCI: fix dereference of ERR_PTR "Lu, Baolu" <baolu.lu@linux.intel.com> - 2015-09-21 04:50 +0200
    Re: [PATCH] USB: EHCI: fix dereference of ERR_PTR Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-09-21 07:00 +0200

csiph-web