From: Guangshuo Li <lgs201920130244@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Kees Cook <kees@kernel.org>, Duoming Zhou <duoming@zju.edu.cn>,
Guangshuo Li <lgs201920130244@gmail.com>,
Li Yang <leoyang.li@nxp.com>, Anatolij Gustschin <agust@denx.de>,
linux-usb@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] usb: phy: fsl-usb: clear fsl_otg_dev after freeing it
Date: Wed, 8 Jul 2026 14:45:49 +0800 [thread overview]
Message-ID: <20260708064549.719147-1-lgs201920130244@gmail.com> (raw)
fsl_otg_dev is a file-scoped singleton pointer and is used by
fsl_otg_conf() to decide whether the OTG device has already been
initialized.
fsl_otg_remove() frees fsl_otg_dev but leaves the global pointer
unchanged. A later bind can therefore see a non-NULL dangling pointer,
skip initialization, and continue using freed memory through the global
fsl_otg_dev pointer.
Clear fsl_otg_dev after freeing it so that a later probe does not treat a
dangling pointer as an initialized device.
Fixes: 0807c500a1a6 ("USB: add Freescale USB OTG Transceiver driver")
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
drivers/usb/phy/phy-fsl-usb.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
index 35d79f11b03d..0b5e937633f4 100644
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -997,6 +997,7 @@ static void fsl_otg_remove(struct platform_device *pdev)
fsl_otg_uninit_timers();
kfree(fsl_otg_dev->phy.otg);
kfree(fsl_otg_dev);
+ fsl_otg_dev = NULL;
if (pdata->exit)
pdata->exit(pdev);
--
2.43.0
next reply other threads:[~2026-07-08 6:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 6:45 Guangshuo Li [this message]
2026-07-10 13:17 ` [PATCH] usb: phy: fsl-usb: clear fsl_otg_dev after freeing it Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260708064549.719147-1-lgs201920130244@gmail.com \
--to=lgs201920130244@gmail.com \
--cc=agust@denx.de \
--cc=duoming@zju.edu.cn \
--cc=gregkh@linuxfoundation.org \
--cc=kees@kernel.org \
--cc=leoyang.li@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox