diff mbox series

[2/2] usb: dwc3: st: add missing depopulate in probe error path

Message ID 20240814093957.37940-2-krzysztof.kozlowski@linaro.org (mailing list archive)
State Accepted
Commit cd4897bfd14f6a5388b21ba45a066541a0425199
Headers show
Series [1/2] usb: dwc3: st: fix probed platform device ref count on probe error path | expand

Commit Message

Krzysztof Kozlowski Aug. 14, 2024, 9:39 a.m. UTC
Depopulate device in probe error paths to fix leak of children
resources.

Fixes: f83fca0707c6 ("usb: dwc3: add ST dwc3 glue layer to manage dwc3 HC")
Cc: <stable@vger.kernel.org>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

---

Context of my other cleanup patches (separate series to be sent soon)
will depend on this.
---
 drivers/usb/dwc3/dwc3-st.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Patrice CHOTARD Aug. 14, 2024, 3:40 p.m. UTC | #1
On 8/14/24 11:39, Krzysztof Kozlowski wrote:
> Depopulate device in probe error paths to fix leak of children
> resources.
> 
> Fixes: f83fca0707c6 ("usb: dwc3: add ST dwc3 glue layer to manage dwc3 HC")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> 
> ---
> 
> Context of my other cleanup patches (separate series to be sent soon)
> will depend on this.
> ---
>  drivers/usb/dwc3/dwc3-st.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/dwc3/dwc3-st.c b/drivers/usb/dwc3/dwc3-st.c
> index a9cb04043f08..c8c7cd0c1796 100644
> --- a/drivers/usb/dwc3/dwc3-st.c
> +++ b/drivers/usb/dwc3/dwc3-st.c
> @@ -266,7 +266,7 @@ static int st_dwc3_probe(struct platform_device *pdev)
>  	if (!child_pdev) {
>  		dev_err(dev, "failed to find dwc3 core device\n");
>  		ret = -ENODEV;
> -		goto err_node_put;
> +		goto depopulate;
>  	}
>  
>  	dwc3_data->dr_mode = usb_get_dr_mode(&child_pdev->dev);
> @@ -282,6 +282,7 @@ static int st_dwc3_probe(struct platform_device *pdev)
>  	ret = st_dwc3_drd_init(dwc3_data);
>  	if (ret) {
>  		dev_err(dev, "drd initialisation failed\n");
> +		of_platform_depopulate(dev);
>  		goto undo_softreset;
>  	}
>  
> @@ -291,6 +292,8 @@ static int st_dwc3_probe(struct platform_device *pdev)
>  	platform_set_drvdata(pdev, dwc3_data);
>  	return 0;
>  
> +depopulate:
> +	of_platform_depopulate(dev);
>  err_node_put:
>  	of_node_put(child);
>  undo_softreset:

Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>

Thanks
Patrice
Thinh Nguyen Aug. 14, 2024, 11:19 p.m. UTC | #2
On Wed, Aug 14, 2024, Krzysztof Kozlowski wrote:
> Depopulate device in probe error paths to fix leak of children
> resources.
> 
> Fixes: f83fca0707c6 ("usb: dwc3: add ST dwc3 glue layer to manage dwc3 HC")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> 
> ---
> 
> Context of my other cleanup patches (separate series to be sent soon)
> will depend on this.
> ---
>  drivers/usb/dwc3/dwc3-st.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/dwc3/dwc3-st.c b/drivers/usb/dwc3/dwc3-st.c
> index a9cb04043f08..c8c7cd0c1796 100644
> --- a/drivers/usb/dwc3/dwc3-st.c
> +++ b/drivers/usb/dwc3/dwc3-st.c
> @@ -266,7 +266,7 @@ static int st_dwc3_probe(struct platform_device *pdev)
>  	if (!child_pdev) {
>  		dev_err(dev, "failed to find dwc3 core device\n");
>  		ret = -ENODEV;
> -		goto err_node_put;
> +		goto depopulate;
>  	}
>  
>  	dwc3_data->dr_mode = usb_get_dr_mode(&child_pdev->dev);
> @@ -282,6 +282,7 @@ static int st_dwc3_probe(struct platform_device *pdev)
>  	ret = st_dwc3_drd_init(dwc3_data);
>  	if (ret) {
>  		dev_err(dev, "drd initialisation failed\n");
> +		of_platform_depopulate(dev);
>  		goto undo_softreset;
>  	}
>  
> @@ -291,6 +292,8 @@ static int st_dwc3_probe(struct platform_device *pdev)
>  	platform_set_drvdata(pdev, dwc3_data);
>  	return 0;
>  
> +depopulate:
> +	of_platform_depopulate(dev);
>  err_node_put:
>  	of_node_put(child);
>  undo_softreset:
> -- 
> 2.43.0
> 

Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>

Thanks,
Thinh
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/dwc3-st.c b/drivers/usb/dwc3/dwc3-st.c
index a9cb04043f08..c8c7cd0c1796 100644
--- a/drivers/usb/dwc3/dwc3-st.c
+++ b/drivers/usb/dwc3/dwc3-st.c
@@ -266,7 +266,7 @@  static int st_dwc3_probe(struct platform_device *pdev)
 	if (!child_pdev) {
 		dev_err(dev, "failed to find dwc3 core device\n");
 		ret = -ENODEV;
-		goto err_node_put;
+		goto depopulate;
 	}
 
 	dwc3_data->dr_mode = usb_get_dr_mode(&child_pdev->dev);
@@ -282,6 +282,7 @@  static int st_dwc3_probe(struct platform_device *pdev)
 	ret = st_dwc3_drd_init(dwc3_data);
 	if (ret) {
 		dev_err(dev, "drd initialisation failed\n");
+		of_platform_depopulate(dev);
 		goto undo_softreset;
 	}
 
@@ -291,6 +292,8 @@  static int st_dwc3_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, dwc3_data);
 	return 0;
 
+depopulate:
+	of_platform_depopulate(dev);
 err_node_put:
 	of_node_put(child);
 undo_softreset: