usb: musb: da8xx: depopulate OF children on teardown
Subsystems (2)
PATCH v2 1/1 usb: musb: da8xx: depopulate OF children on teardown
da8xx_probe() populates OF child devices before registering the MUSB platform device. If the later MUSB device registration fails, those children remain registered. The remove path also leaves the populated children behind.
Depopulate the children when MUSB device registration fails and after unregistering the MUSB device during remove.
---
Changes since v1: https://lore.kernel.org/all/[email protected]/
- keep the existing of_platform_populate() error unwind target, so both labels remain used and the patch does not introduce an unused-label warning
- limit the commit message to paths where population has succeeded
--- drivers/usb/musb/da8xx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/usb/musb/da8xx.c +4 -1
@@ -577,11 +577,13 @@ static int da8xx_probe(struct platform_device *pdev) ret =PTR_ERR_OR_ZERO (glue->musb);if (ret) {dev_err (&pdev->dev,"failed to register musb device: %d\n" , ret); - goto err_unregister_phy; + goto err_depopulate; }return 0 ; +err_depopulate: +of_platform_depopulate (&pdev->dev); err_unregister_phy:usb_phy_generic_unregister (glue->usb_phy);return ret;
@@ -592,6 +594,7 @@ static void da8xx_remove(struct platform_device *pdev)struct da8xx_glue *glue =platform_get_drvdata (pdev);platform_device_unregister (glue->musb); +of_platform_depopulate (&pdev->dev);usb_phy_generic_unregister (glue->usb_phy); }
Signature · 1 line
2.50.1 (Apple Git-155)
Greg Kroah-Hartman
maintainerQuoted 39 lines · Pengpeng Hou
da8xx_probe()populates OF child devices before registering the MUSB platform device. If the later MUSB device registration fails, those children remain registered. The remove path also leaves the populated children behind.Depopulate the children when MUSB device registration fails and after unregistering the MUSB device during remove.
Signed-off-by Pengpeng Hou <[email protected]>---
Changes since v1: https://lore.kernel.org/all/[email protected]/
- keep the existingof_platform_populate()error unwind target, so both labels remain used and the patch does not introduce an unused-label warning
- limit the commit message to paths where population has succeeded--- drivers/usb/musb/da8xx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/usb/musb/da8xx.c +3
-1@@ -577,11 +577,13 @@ static int da8xx_probe(struct platform_device *pdev) ret =PTR_ERR_OR_ZERO (glue->musb);if (ret) {dev_err (&pdev->dev,"failed to register musb device: %d\n" , ret); - goto err_unregister_phy; + goto err_depopulate; }return 0 ; +err_depopulate: +of_platform_depopulate (&pdev->dev); err_unregister_phy:usb_phy_generic_unregister (glue->usb_phy);return ret;
drivers/usb/musb/da8xx.c static void da8xx_remove(struct platform_device *pdev) · line 597
Quoted 4 lines
drivers/usb/musb/da8xx.c +1
-0@@ -592,6 +594,7 @@ static void da8xx_remove(struct platform_device *pdev)struct da8xx_glue *glue =platform_get_drvdata (pdev);platform_device_unregister (glue->musb); +of_platform_depopulate (&pdev->dev);
This implies that this has always been a bug for the normal remove path? How has this never shown up anywhere?
So shouldn't this be 2 different patches, there are 2 different bugs here, right?
thanks,
greg k-h