* [PATCH 1/5] usb: dwc3: imx8mp: fix device leak at unbind
[not found] <20250724091910.21092-1-johan@kernel.org>
@ 2025-07-24 9:19 ` Johan Hovold
2025-07-24 9:19 ` [PATCH 2/5] usb: dwc3: meson-g12a: fix device leaks " Johan Hovold
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2025-07-24 9:19 UTC (permalink / raw)
To: Greg Kroah-Hartman, Thinh Nguyen, Bin Liu
Cc: Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
linux-usb, linux-kernel, Johan Hovold, stable, Li Jun
Make sure to drop the reference to the dwc3 device taken by
of_find_device_by_node() on probe errors and on driver unbind.
Fixes: 6dd2565989b4 ("usb: dwc3: add imx8mp dwc3 glue layer driver")
Cc: stable@vger.kernel.org # 5.12
Cc: Li Jun <jun.li@nxp.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/usb/dwc3/dwc3-imx8mp.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/dwc3/dwc3-imx8mp.c b/drivers/usb/dwc3/dwc3-imx8mp.c
index 3edc5aca76f9..bce6af82f54c 100644
--- a/drivers/usb/dwc3/dwc3-imx8mp.c
+++ b/drivers/usb/dwc3/dwc3-imx8mp.c
@@ -244,7 +244,7 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
IRQF_ONESHOT, dev_name(dev), dwc3_imx);
if (err) {
dev_err(dev, "failed to request IRQ #%d --> %d\n", irq, err);
- goto depopulate;
+ goto put_dwc3;
}
device_set_wakeup_capable(dev, true);
@@ -252,6 +252,8 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
return 0;
+put_dwc3:
+ put_device(&dwc3_imx->dwc3->dev);
depopulate:
of_platform_depopulate(dev);
remove_swnode:
@@ -265,8 +267,11 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
static void dwc3_imx8mp_remove(struct platform_device *pdev)
{
+ struct dwc3_imx8mp *dwc3_imx = platform_get_drvdata(pdev);
struct device *dev = &pdev->dev;
+ put_device(&dwc3_imx->dwc3->dev);
+
pm_runtime_get_sync(dev);
of_platform_depopulate(dev);
device_remove_software_node(dev);
--
2.49.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/5] usb: dwc3: meson-g12a: fix device leaks at unbind
[not found] <20250724091910.21092-1-johan@kernel.org>
2025-07-24 9:19 ` [PATCH 1/5] usb: dwc3: imx8mp: fix device leak at unbind Johan Hovold
@ 2025-07-24 9:19 ` Johan Hovold
2025-07-24 20:40 ` Martin Blumenstingl
2025-07-24 9:19 ` [PATCH 3/5] usb: gadget: udc: renesas_usb3: fix device leak " Johan Hovold
2025-07-24 9:19 ` [PATCH 4/5] usb: musb: omap2430: " Johan Hovold
3 siblings, 1 reply; 6+ messages in thread
From: Johan Hovold @ 2025-07-24 9:19 UTC (permalink / raw)
To: Greg Kroah-Hartman, Thinh Nguyen, Bin Liu
Cc: Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
linux-usb, linux-kernel, Johan Hovold, stable
Make sure to drop the references taken to the child devices by
of_find_device_by_node() during probe on driver unbind.
Fixes: c99993376f72 ("usb: dwc3: Add Amlogic G12A DWC3 glue")
Cc: stable@vger.kernel.org # 5.2
Cc: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/usb/dwc3/dwc3-meson-g12a.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c
index 7d80bf7b18b0..55e144ba8cfc 100644
--- a/drivers/usb/dwc3/dwc3-meson-g12a.c
+++ b/drivers/usb/dwc3/dwc3-meson-g12a.c
@@ -837,6 +837,9 @@ static void dwc3_meson_g12a_remove(struct platform_device *pdev)
usb_role_switch_unregister(priv->role_switch);
+ put_device(priv->switch_desc.udc);
+ put_device(priv->switch_desc.usb2_port);
+
of_platform_depopulate(dev);
for (i = 0 ; i < PHY_COUNT ; ++i) {
--
2.49.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 2/5] usb: dwc3: meson-g12a: fix device leaks at unbind
2025-07-24 9:19 ` [PATCH 2/5] usb: dwc3: meson-g12a: fix device leaks " Johan Hovold
@ 2025-07-24 20:40 ` Martin Blumenstingl
0 siblings, 0 replies; 6+ messages in thread
From: Martin Blumenstingl @ 2025-07-24 20:40 UTC (permalink / raw)
To: Johan Hovold
Cc: Greg Kroah-Hartman, Thinh Nguyen, Bin Liu, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Neil Armstrong, Kevin Hilman, Jerome Brunet, linux-usb,
linux-kernel, stable
On Thu, Jul 24, 2025 at 11:19 AM Johan Hovold <johan@kernel.org> wrote:
>
> Make sure to drop the references taken to the child devices by
> of_find_device_by_node() during probe on driver unbind.
>
> Fixes: c99993376f72 ("usb: dwc3: Add Amlogic G12A DWC3 glue")
> Cc: stable@vger.kernel.org # 5.2
> Cc: Neil Armstrong <neil.armstrong@linaro.org>
> Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Thank you for finding and fixing this!
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/5] usb: gadget: udc: renesas_usb3: fix device leak at unbind
[not found] <20250724091910.21092-1-johan@kernel.org>
2025-07-24 9:19 ` [PATCH 1/5] usb: dwc3: imx8mp: fix device leak at unbind Johan Hovold
2025-07-24 9:19 ` [PATCH 2/5] usb: dwc3: meson-g12a: fix device leaks " Johan Hovold
@ 2025-07-24 9:19 ` Johan Hovold
2025-07-24 9:19 ` [PATCH 4/5] usb: musb: omap2430: " Johan Hovold
3 siblings, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2025-07-24 9:19 UTC (permalink / raw)
To: Greg Kroah-Hartman, Thinh Nguyen, Bin Liu
Cc: Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
linux-usb, linux-kernel, Johan Hovold, stable, Yoshihiro Shimoda
Make sure to drop the reference to the companion device taken during
probe when the driver is unbound.
Fixes: 39facfa01c9f ("usb: gadget: udc: renesas_usb3: Add register of usb role switch")
Cc: stable@vger.kernel.org # 4.19
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/usb/gadget/udc/renesas_usb3.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
index 3e4d56457597..d23b1762e0e4 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -2657,6 +2657,7 @@ static void renesas_usb3_remove(struct platform_device *pdev)
struct renesas_usb3 *usb3 = platform_get_drvdata(pdev);
debugfs_remove_recursive(usb3->dentry);
+ put_device(usb3->host_dev);
device_remove_file(&pdev->dev, &dev_attr_role);
cancel_work_sync(&usb3->role_work);
--
2.49.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 4/5] usb: musb: omap2430: fix device leak at unbind
[not found] <20250724091910.21092-1-johan@kernel.org>
` (2 preceding siblings ...)
2025-07-24 9:19 ` [PATCH 3/5] usb: gadget: udc: renesas_usb3: fix device leak " Johan Hovold
@ 2025-07-24 9:19 ` Johan Hovold
2025-07-30 22:33 ` Kevin Hilman
3 siblings, 1 reply; 6+ messages in thread
From: Johan Hovold @ 2025-07-24 9:19 UTC (permalink / raw)
To: Greg Kroah-Hartman, Thinh Nguyen, Bin Liu
Cc: Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
linux-usb, linux-kernel, Johan Hovold, stable, Roger Quadros
Make sure to drop the reference to the control device taken by
of_find_device_by_node() during probe when the driver is unbound.
Fixes: 8934d3e4d0e7 ("usb: musb: omap2430: Don't use omap_get_control_dev()")
Cc: stable@vger.kernel.org # 3.13
Cc: Roger Quadros <rogerq@kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/usb/musb/omap2430.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 2970967a4fd2..36f756f9b7f6 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -400,7 +400,7 @@ static int omap2430_probe(struct platform_device *pdev)
ret = platform_device_add_resources(musb, pdev->resource, pdev->num_resources);
if (ret) {
dev_err(&pdev->dev, "failed to add resources\n");
- goto err2;
+ goto err_put_control_otghs;
}
if (populate_irqs) {
@@ -413,7 +413,7 @@ static int omap2430_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
ret = -EINVAL;
- goto err2;
+ goto err_put_control_otghs;
}
musb_res[i].start = res->start;
@@ -441,14 +441,14 @@ static int omap2430_probe(struct platform_device *pdev)
ret = platform_device_add_resources(musb, musb_res, i);
if (ret) {
dev_err(&pdev->dev, "failed to add IRQ resources\n");
- goto err2;
+ goto err_put_control_otghs;
}
}
ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
if (ret) {
dev_err(&pdev->dev, "failed to add platform_data\n");
- goto err2;
+ goto err_put_control_otghs;
}
pm_runtime_enable(glue->dev);
@@ -463,7 +463,9 @@ static int omap2430_probe(struct platform_device *pdev)
err3:
pm_runtime_disable(glue->dev);
-
+err_put_control_otghs:
+ if (!IS_ERR(glue->control_otghs))
+ put_device(glue->control_otghs);
err2:
platform_device_put(musb);
@@ -477,6 +479,8 @@ static void omap2430_remove(struct platform_device *pdev)
platform_device_unregister(glue->musb);
pm_runtime_disable(glue->dev);
+ if (!IS_ERR(glue->control_otghs))
+ put_device(glue->control_otghs);
}
#ifdef CONFIG_PM
--
2.49.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 4/5] usb: musb: omap2430: fix device leak at unbind
2025-07-24 9:19 ` [PATCH 4/5] usb: musb: omap2430: " Johan Hovold
@ 2025-07-30 22:33 ` Kevin Hilman
0 siblings, 0 replies; 6+ messages in thread
From: Kevin Hilman @ 2025-07-30 22:33 UTC (permalink / raw)
To: Johan Hovold, Greg Kroah-Hartman, Thinh Nguyen, Bin Liu
Cc: Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Neil Armstrong, Jerome Brunet, Martin Blumenstingl, linux-usb,
linux-kernel, Johan Hovold, stable, Roger Quadros
Johan Hovold <johan@kernel.org> writes:
> Make sure to drop the reference to the control device taken by
> of_find_device_by_node() during probe when the driver is unbound.
>
> Fixes: 8934d3e4d0e7 ("usb: musb: omap2430: Don't use omap_get_control_dev()")
> Cc: stable@vger.kernel.org # 3.13
> Cc: Roger Quadros <rogerq@kernel.org>
> Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Kevin Hilman <khilman@baylibre.com>
> ---
> drivers/usb/musb/omap2430.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
> index 2970967a4fd2..36f756f9b7f6 100644
> --- a/drivers/usb/musb/omap2430.c
> +++ b/drivers/usb/musb/omap2430.c
> @@ -400,7 +400,7 @@ static int omap2430_probe(struct platform_device *pdev)
> ret = platform_device_add_resources(musb, pdev->resource, pdev->num_resources);
> if (ret) {
> dev_err(&pdev->dev, "failed to add resources\n");
> - goto err2;
> + goto err_put_control_otghs;
> }
>
> if (populate_irqs) {
> @@ -413,7 +413,7 @@ static int omap2430_probe(struct platform_device *pdev)
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> if (!res) {
> ret = -EINVAL;
> - goto err2;
> + goto err_put_control_otghs;
> }
>
> musb_res[i].start = res->start;
> @@ -441,14 +441,14 @@ static int omap2430_probe(struct platform_device *pdev)
> ret = platform_device_add_resources(musb, musb_res, i);
> if (ret) {
> dev_err(&pdev->dev, "failed to add IRQ resources\n");
> - goto err2;
> + goto err_put_control_otghs;
> }
> }
>
> ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
> if (ret) {
> dev_err(&pdev->dev, "failed to add platform_data\n");
> - goto err2;
> + goto err_put_control_otghs;
> }
>
> pm_runtime_enable(glue->dev);
> @@ -463,7 +463,9 @@ static int omap2430_probe(struct platform_device *pdev)
>
> err3:
> pm_runtime_disable(glue->dev);
> -
> +err_put_control_otghs:
> + if (!IS_ERR(glue->control_otghs))
> + put_device(glue->control_otghs);
> err2:
> platform_device_put(musb);
>
> @@ -477,6 +479,8 @@ static void omap2430_remove(struct platform_device *pdev)
>
> platform_device_unregister(glue->musb);
> pm_runtime_disable(glue->dev);
> + if (!IS_ERR(glue->control_otghs))
> + put_device(glue->control_otghs);
> }
>
> #ifdef CONFIG_PM
> --
> 2.49.1
^ permalink raw reply [flat|nested] 6+ messages in thread