[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2026011935-ransack-unworldly-7cf5@gregkh>
Date: Mon, 19 Jan 2026 10:33:31 +0100
From: Greg KH <gregkh@...uxfoundation.org>
To: Abhash Kumar Jha <a-kumar2@...com>
Cc: pawell@...ence.com, peter.chen@...nel.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
linux-usb@...r.kernel.org, rogerq@...nel.org, u-kumar1@...com,
p-mantena@...com, theo.lebrun@...tlin.com
Subject: Re: [PATCH] usb: cdns3: host: Add null check for host_device before
accessing its members
On Mon, Jan 19, 2026 at 01:52:42PM +0530, Abhash Kumar Jha wrote:
> In cases when the xhci device is not populated, we see a nullptr
> exception when resuming.
How can that happen? What changed to cause this?
> Add a nullptr check for the host_dev before accessing its private data.
>
> Fixes: 3a85c1011540 ("usb: host: cdns3: forward lost power information to xhci")
No cc: stable?
> Signed-off-by: Abhash Kumar Jha <a-kumar2@...com>
> ---
> drivers/usb/cdns3/host.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/cdns3/host.c b/drivers/usb/cdns3/host.c
> index f0df114c2b53b..8cc7fc1de6193 100644
> --- a/drivers/usb/cdns3/host.c
> +++ b/drivers/usb/cdns3/host.c
> @@ -141,9 +141,12 @@ static void cdns_host_exit(struct cdns *cdns)
> static int cdns_host_resume(struct cdns *cdns, bool power_lost)
> {
> struct usb_hcd *hcd = platform_get_drvdata(cdns->host_dev);
> - struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd);
> + struct xhci_plat_priv *priv;
>
> - priv->power_lost = power_lost;
> + if (hcd) {
> + priv = hcd_to_xhci_priv(hcd);
> + priv->power_lost = power_lost;
> + }
Shouldn't you be returning an error if something went wrong?
And what protects hcd from changing right after you tested it?
thanks,
greg k-h
Powered by blists - more mailing lists