Re: [PATCH] usb: xhci_plat_remove: avoid NULL dereference

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 22.7.2022 18.38, Alexey Sheplyakov wrote:
Hello,

On Fri, Jul 22, 2022 at 05:14:14PM +0200, Greg KH wrote:
On Fri, Jul 22, 2022 at 06:17:00PM +0400, Alexey Sheplyakov wrote:
Since commit 4736ebd7fcaff1eb8481c140ba494962847d6e0a ("usb: host:
xhci-plat: omit shared hcd if either root hub has no ports")
xhci->shared_hcd can be NULL, which causes the following Oops
on reboot:

Thanks for debugging this.


But really, why is hcd NULL at all?

xhci_plat_remove does this:

396	    struct usb_hcd *shared_hcd = xhci->shared_hcd;
397
398         pm_runtime_get_sync(&dev->dev);
399         xhci->xhc_state |= XHCI_STATE_REMOVING;
400
401         usb_remove_hcd(shared_hcd);
402         xhci->shared_hcd = NULL;

However with e0fe986972f5 ("usb: host: xhci-plat: prepare operation w/o
shared hcd") and 4736ebd7fcaf ("usb: host: xhci-plat: omit shared hcd
if either root hub has no ports") it's OK to have no shared hcd, and
xhci->shared_hcd is NULL in this case.

So one should check for NULL either in xhci_plat_remove (and possibly
other users of usb_remove_hcd), or in usb_remove_hcd itself.


Yes, xhci_plat_remove() should be fixed.
It really shouldn't call usb_remove_hcd(NULL), I'll write a patch for it.

No harm in checking hcd is valid in usb_remove_hcd() like this patch either.
Thanks
-Mathias



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux