Skip to content

Commit 51392a1

Browse files
jhovoldgregkh
authored andcommitted
USB: dwc3: qcom: fix resource leaks on probe deferral
The driver needs to deregister and free the newly allocated dwc3 core platform device on ACPI probe errors (e.g. probe deferral) and on driver unbind but instead it leaked those resources while erroneously dropping a reference to the parent platform device which is still in use. For OF probing the driver takes a reference to the dwc3 core platform device which has also always been leaked. Fix the broken ACPI tear down and make sure to drop the dwc3 core reference for both OF and ACPI. Fixes: 8fd95da ("usb: dwc3: qcom: Release the correct resources in dwc3_qcom_remove()") Fixes: 2bc0235 ("usb: dwc3: qcom: Add support for booting with ACPI") Fixes: a4333c3 ("usb: dwc3: Add Qualcomm DWC3 glue driver") Cc: [email protected] # 4.18 Cc: Christophe JAILLET <[email protected]> Cc: Lee Jones <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Acked-by: Andrew Halaney <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent aee70a1 commit 51392a1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/usb/dwc3/dwc3-qcom.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,7 @@ static int dwc3_qcom_of_register_core(struct platform_device *pdev)
754754
if (!qcom->dwc3) {
755755
ret = -ENODEV;
756756
dev_err(dev, "failed to get dwc3 platform device\n");
757+
of_platform_depopulate(dev);
757758
}
758759

759760
node_put:
@@ -895,7 +896,7 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
895896

896897
if (ret) {
897898
dev_err(dev, "failed to register DWC3 Core, err=%d\n", ret);
898-
goto depopulate;
899+
goto clk_disable;
899900
}
900901

901902
ret = dwc3_qcom_interconnect_init(qcom);
@@ -930,7 +931,8 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
930931
if (np)
931932
of_platform_depopulate(&pdev->dev);
932933
else
933-
platform_device_put(pdev);
934+
platform_device_del(qcom->dwc3);
935+
platform_device_put(qcom->dwc3);
934936
clk_disable:
935937
for (i = qcom->num_clocks - 1; i >= 0; i--) {
936938
clk_disable_unprepare(qcom->clks[i]);
@@ -953,7 +955,8 @@ static void dwc3_qcom_remove(struct platform_device *pdev)
953955
if (np)
954956
of_platform_depopulate(&pdev->dev);
955957
else
956-
platform_device_put(pdev);
958+
platform_device_del(qcom->dwc3);
959+
platform_device_put(qcom->dwc3);
957960

958961
for (i = qcom->num_clocks - 1; i >= 0; i--) {
959962
clk_disable_unprepare(qcom->clks[i]);

0 commit comments

Comments
 (0)