* [PATCH] usb: chipidea: ci_hdrc_imx: link to usbmisc to fix NULL deref on unbind
@ 2026-12-02 8:28 Prasanth R
0 siblings, 0 replies; only message 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] only message in thread
only message in thread, other threads:[~2026-12-02 8:28 UTC | newest]
Thread overview: (only message) (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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox