usb: dwc3: core: fix some leaks in probe
Subsystems (3)
PATCH 1/1 usb: dwc3: core: fix some leaks in probe
The dwc3_get_properties() function calls:
dwc->usb_psy = power_supply_get_by_name(usb_psy_name);
so there is some additional clean up required on these error paths.
Fixes 6f0764b5adea ("usb: dwc3: add a power supply for current control")
Signed-off-by Dan Carpenter <[email protected]>
--- drivers/usb/dwc3/core.c | 58 +++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 22 deletions(-)
drivers/usb/dwc3/core.c +36 -22
@@ -1753,8 +1753,10 @@ static int dwc3_probe(struct platform_device *pdev)dwc3_get_properties (dwc); dwc->reset =devm_reset_control_array_get_optional_shared (dev); -if (IS_ERR (dwc->reset)) -return PTR_ERR (dwc->reset); +if (IS_ERR (dwc->reset)) { + ret =PTR_ERR (dwc->reset); + goto put_usb_psy; + }if (dev->of_node) {/*
@@ -1764,45 +1766,57 @@ static int dwc3_probe(struct platform_device *pdev)* check for them to retain backwards compatibility. */ dwc->bus_clk =devm_clk_get_optional (dev,"bus_early" ); -if (IS_ERR (dwc->bus_clk)) -return dev_err_probe (dev,PTR_ERR (dwc->bus_clk), -"could not get bus clock\n" ); +if (IS_ERR (dwc->bus_clk)) { + ret =dev_err_probe (dev,PTR_ERR (dwc->bus_clk), +"could not get bus clock\n" ); + goto put_usb_psy; + }if (dwc->bus_clk ==NULL ) { dwc->bus_clk =devm_clk_get_optional (dev,"bus_clk" ); -if (IS_ERR (dwc->bus_clk)) -return dev_err_probe (dev,PTR_ERR (dwc->bus_clk), -"could not get bus clock\n" ); +if (IS_ERR (dwc->bus_clk)) { + ret =dev_err_probe (dev,PTR_ERR (dwc->bus_clk), +"could not get bus clock\n" ); + goto put_usb_psy; + } } dwc->ref_clk =devm_clk_get_optional (dev,"ref" ); -if (IS_ERR (dwc->ref_clk)) -return dev_err_probe (dev,PTR_ERR (dwc->ref_clk), -"could not get ref clock\n" ); +if (IS_ERR (dwc->ref_clk)) { + ret =dev_err_probe (dev,PTR_ERR (dwc->ref_clk), +"could not get ref clock\n" ); + goto put_usb_psy; + }if (dwc->ref_clk ==NULL ) { dwc->ref_clk =devm_clk_get_optional (dev,"ref_clk" ); -if (IS_ERR (dwc->ref_clk)) -return dev_err_probe (dev,PTR_ERR (dwc->ref_clk), -"could not get ref clock\n" ); +if (IS_ERR (dwc->ref_clk)) { + ret =dev_err_probe (dev,PTR_ERR (dwc->ref_clk), +"could not get ref clock\n" ); + goto put_usb_psy; + } } dwc->susp_clk =devm_clk_get_optional (dev,"suspend" ); -if (IS_ERR (dwc->susp_clk)) -return dev_err_probe (dev,PTR_ERR (dwc->susp_clk), -"could not get suspend clock\n" ); +if (IS_ERR (dwc->susp_clk)) { + ret =dev_err_probe (dev,PTR_ERR (dwc->susp_clk), +"could not get suspend clock\n" ); + goto put_usb_psy; + }if (dwc->susp_clk ==NULL ) { dwc->susp_clk =devm_clk_get_optional (dev,"suspend_clk" ); -if (IS_ERR (dwc->susp_clk)) -return dev_err_probe (dev,PTR_ERR (dwc->susp_clk), -"could not get suspend clock\n" ); +if (IS_ERR (dwc->susp_clk)) { + ret =dev_err_probe (dev,PTR_ERR (dwc->susp_clk), +"could not get suspend clock\n" ); + goto put_usb_psy; + } } } ret =reset_control_deassert (dwc->reset);if (ret) -return ret; + goto put_usb_psy; ret =dwc3_clk_enable (dwc);if (ret)
@@ -1909,7 +1923,7 @@ static int dwc3_probe(struct platform_device *pdev)dwc3_clk_disable (dwc); assert_reset:reset_control_assert (dwc->reset); - +put_usb_psy:if (dwc->usb_psy)power_supply_put (dwc->usb_psy);
Signature · 1 line
2.35.1