lkml.org 
[lkml]   [2023]   [Mar]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] usb: host: xhci: Add a NULL check of hcd in xhci_plat_remove()
On 23.3.2023 10.13, Jia-Ju Bai wrote:
> In a previous commit d7de14d74d65 ("usb: xhci_plat_remove: avoid NULL
> dereference"), hcd can be NULL in usb_remove_hcd(), and thus it should
> be checked before being used.

hcd shouldn't be null in usb_remove_hcd()
That was a bug which was properly fixed shortly after in:

4a593a62a9e3 xhci: Fix null pointer dereference in remove if xHC has only one roothub

I guess commit d7de14d74d65 ("usb: xhci_plat_remove: avoid NULL dereference") Isn't really
needed either anymore, but no harm in keeping it.

>
> However, in the call stack of this commit, hci is also used to get xhci:
> > xhci_plat_remove()
> xhci = hcd_to_xhci(hcd)
> usb_hcd_is_primary_hcd(hcd)
> if (!hcd->primary_hcd) -> No check for hcd
> primary_hcd = hcd->primary_hcd; -> No check for hcd
> usb_remove_hcd(hcd)
> if (!hcd) -> Add a check by the previous commit

These hcd checks shouldn't be needed.

Thanks
Mathias

\
 
 \ /
  Last update: 2023-03-27 01:15    [W:0.045 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site