Re: [PATCH v2 resend] drivers: usb: host: fix NULL pointer dereferences triggered by unhandled errors in xhci_create_rhub_port_array()

From: Mathias Nyman
Date: Thu Apr 28 2022 - 08:42:58 EST


On 28.4.2022 12.23, Zixuan Fu wrote:
> In xhci_create_rhub_port_array(), when rhub->num_ports is zero,
> rhub->ports would not be set; when kcalloc_node() fails, rhub->ports
> would be set to NULL. In these two cases, xhci_create_rhub_port_array()
> just returns void, and thus its callers are unaware of the error.
>
> Then rhub->ports is dereferenced in xhci_usb3_hub_descriptor() or
> xhci_usb2_hub_descriptor().

As it turned out this dereference is only an issue if kcalloc_node() failed,
not if rhub->num_ports is zero.

So this is more of a theoretical issue. Not urgent, not for stable.

So as Greg suggested its probably better to add this fix on top of
the one roothub support series it conflicts with.


Thanks
Mathias