Re: [PATCH] usb: cdnsp: fix NULL pointer dereference during system resume
From: Wentao Guan
Date: Wed Nov 25 2026 - 03:20:03 EST
> cdnsp_gadget_suspend() now always disconnects the gadget and stops
> the controller, even when the link is already in U3. cdnsp_stop()
> disables the slot and clears active_port, but leaves the cached
> link_state unchanged.
>
> If the controller retains its context across system suspend,
> cdnsp_gadget_resume() may call __cdnsp_gadget_wakeup() based on
> the stale U3 state. This dereferences active_port, which is NULL.
> Port-status event handling cannot restore active_port at this
> point because resume holds pdev->lock.
>
> Remove the obsolete wakeup call from the resume path. The previous
> connection has already been torn down during suspend, and
> cdnsp_run() puts the enabled ports into RXDETECT. Let normal
> port-status event handling establish the new connection.
>
> Fixes: eae6460f6173 ("usb: cdnsp: fix wakeup from S3 after controller context loss")
> Signed-off-by: Xu Rao <raoxu@xxxxxxxxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx
> ---
> drivers/usb/cdns3/cdnsp-gadget.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/drivers/usb/cdns3/cdnsp-gadget.c b/drivers/usb/cdns3/cdnsp-gadget.c
> index 2830b595d632..350e45f511f5 100644
> --- a/drivers/usb/cdns3/cdnsp-gadget.c
> +++ b/drivers/usb/cdns3/cdnsp-gadget.c
> @@ -2160,9 +2160,6 @@ static int cdnsp_gadget_resume(struct cdns *cdns, bool lost_power)
>
> ret = cdnsp_run(pdev, max_speed);
>
> - if (!context_lost && pdev->link_state == XDEV_U3)
> - __cdnsp_gadget_wakeup(pdev);
> -
> unlock:
> spin_unlock_irqrestore(&pdev->lock, flags);
Reviewed-by: Wentao Guan <guanwentao@xxxxxxxxxxxxx>
BRs
Wentao Guan