* [PATCH] usb: chipidea: ci_hdrc_imx: link to usbmisc to fix NULL deref on unbind
@ 2026-12-02 8:28 Prasanth R
2026-12-02 8:33 ` sashiko-bot
2026-12-02 20:27 ` Frank Li
0 siblings, 2 replies; 3+ messages in thread
From: Prasanth R @ 2026-12-02 8:28 UTC (permalink / raw)
To: Peter Chen, Greg Kroah-Hartman
Cc: Frank Li, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
linux-usb, imx, linux-arm-kernel, linux-kernel, Prasanth R
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@lineo.co.jp>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: chipidea: ci_hdrc_imx: link to usbmisc to fix NULL deref on unbind
2026-12-02 8:28 [PATCH] usb: chipidea: ci_hdrc_imx: link to usbmisc to fix NULL deref on unbind Prasanth R
@ 2026-12-02 8:33 ` sashiko-bot
2026-12-02 20:27 ` Frank Li
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-12-02 8:33 UTC (permalink / raw)
To: Prasanth R; +Cc: linux-usb
> 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@lineo.co.jp>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202082820.3764321-1-ragaprasanth@gmail.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: chipidea: ci_hdrc_imx: link to usbmisc to fix NULL deref on unbind
2026-12-02 8:28 [PATCH] usb: chipidea: ci_hdrc_imx: link to usbmisc to fix NULL deref on unbind Prasanth R
2026-12-02 8:33 ` sashiko-bot
@ 2026-12-02 20:27 ` Frank Li
1 sibling, 0 replies; 3+ messages in thread
From: Frank Li @ 2026-12-02 20:27 UTC (permalink / raw)
To: Prasanth R
Cc: Peter Chen, Greg Kroah-Hartman, Frank Li, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, linux-usb, imx,
linux-arm-kernel, linux-kernel
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@lineo.co.jp>
> ---
Reviewed-by: Frank Li <Frank.Li@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
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-02 20:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 8:28 [PATCH] usb: chipidea: ci_hdrc_imx: link to usbmisc to fix NULL deref on unbind Prasanth R
2026-12-02 8:33 ` sashiko-bot
2026-12-02 20:27 ` Frank Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox