[PATCH] usb: chipidea: ci_hdrc_imx: link to usbmisc to fix NULL deref on unbind

Frank Li Frank.li at oss.nxp.com
Wed Dec 2 12:27:34 PST 2026


On Wed, Dec 02, 2026 at 05:28:20PM +0900, Prasanth R wrote:
> ci_hdrc_imx uses the usbmisc driver data in suspend and resume, but
> nothing keeps usbmisc bound. After usbmisc is unbound, its driver data
> is NULL and the next resume crashes. On the i.MX6Q SABRE-SD, with the
> USB host port runtime suspended:
>
>   echo 2184800.usbmisc > /sys/bus/platform/drivers/usbmisc_imx/unbind
>   echo 2184200.usb > /sys/bus/platform/drivers/imx_usb/unbind
>
>   BUG: KASAN: null-ptr-deref in imx_usbmisc_resume+0x34/0x2b4
>   Read of size 4 at addr 0000000c
>
> Add a device link from the controller to usbmisc, so unbinding usbmisc
> unbinds the controller first.
>
> Fixes: e14db48dfcf3 ("usb: chipidea: imx: add runtime power management support")
>
> Signed-off-by: Prasanth R <prasanth.r at lineo.co.jp>
> ---

Reviewed-by: Frank Li <Frank.Li at nxp.com>

> Tested on the i.MX6Q SABRE-SD with KASAN: no crash after the fix,
> and both USB ports bind again after usbmisc is bound again.
> Suspend to RAM and resume still work.
>
> I used an AI assistant (Claude) to find this and write the change.
>
>  drivers/usb/chipidea/ci_hdrc_imx.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
> index 282314eea..af5485e1d 100644
> --- a/drivers/usb/chipidea/ci_hdrc_imx.c
> +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
> @@ -170,6 +170,12 @@ static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev)
>  	}
>  	data->dev = &misc_pdev->dev;
>
> +	/* Keep usbmisc bound while this controller uses it */
> +	if (!device_link_add(dev, &misc_pdev->dev, DL_FLAG_AUTOREMOVE_CONSUMER)) {
> +		put_device(&misc_pdev->dev);
> +		return ERR_PTR(-EINVAL);
> +	}
> +
>  	/*
>  	 * Check the various over current related properties. If over current
>  	 * detection is disabled we're not interested in the polarity.
> --
> 2.34.1
>
>



More information about the linux-arm-kernel mailing list