]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
usb: musb: omap2430: fix device leak at unbind
authorJohan Hovold <johan@kernel.org>
Thu, 21 Aug 2025 15:09:57 +0000 (11:09 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:24:32 +0000 (16:24 +0200)
[ Upstream commit 1473e9e7679bd4f5a62d1abccae894fb86de280f ]

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>
Link: https://lore.kernel.org/r/20250724091910.21092-5-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[ Removed populate_irqs-related goto changes ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/musb/omap2430.c

index 5f5d9b59ce7ef4afc3b7c779d0188d3509414e1d..10ff09680798b8329883171a5ee9d331aaa3e44d 100644 (file)
@@ -406,13 +406,13 @@ static int omap2430_probe(struct platform_device *pdev)
                        ARRAY_SIZE(musb_resources));
        if (ret) {
                dev_err(&pdev->dev, "failed to add 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);
@@ -427,7 +427,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);
 
@@ -441,6 +443,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