2021-11-07 20:38:18

by Christophe JAILLET

[permalink] [raw]
Subject: [PATCH] usb: gadget: udc-xilinx: Fix an error handling path in 'xudc_probe()'

A successful 'clk_prepare_enable()' call should be balanced by a
corresponding 'clk_disable_unprepare()' call in the error handling path
of the probe, as already done in the remove function.

Fixes: 24749229211c ("usb: gadget: udc-xilinx: Add clock support")
Signed-off-by: Christophe JAILLET <[email protected]>
---
drivers/usb/gadget/udc/udc-xilinx.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/udc-xilinx.c b/drivers/usb/gadget/udc/udc-xilinx.c
index f5ca670776a3..857159dd5ae0 100644
--- a/drivers/usb/gadget/udc/udc-xilinx.c
+++ b/drivers/usb/gadget/udc/udc-xilinx.c
@@ -2136,7 +2136,7 @@ static int xudc_probe(struct platform_device *pdev)

ret = usb_add_gadget_udc(&pdev->dev, &udc->gadget);
if (ret)
- goto fail;
+ goto err_disable_unprepare_clk;

udc->dev = &udc->gadget.dev;

@@ -2155,6 +2155,9 @@ static int xudc_probe(struct platform_device *pdev)
udc->dma_enabled ? "with DMA" : "without DMA");

return 0;
+
+err_disable_unprepare_clk:
+ clk_disable_unprepare(udc->clk);
fail:
dev_err(&pdev->dev, "probe failed, %d\n", ret);
return ret;
--
2.30.2


2021-11-08 09:11:49

by Shubhrajyoti Datta

[permalink] [raw]
Subject: RE: [PATCH] usb: gadget: udc-xilinx: Fix an error handling path in 'xudc_probe()'



> -----Original Message-----
> From: Christophe JAILLET <[email protected]>
> Sent: Sunday, November 7, 2021 9:56 PM
> To: [email protected]; [email protected]; Michal Simek
> <[email protected]>; [email protected]; [email protected];
> [email protected]; Shubhrajyoti Datta <[email protected]>
> Cc: [email protected]; [email protected]; linux-
> [email protected]; [email protected]; Christophe JAILLET
> <[email protected]>
> Subject: [PATCH] usb: gadget: udc-xilinx: Fix an error handling path in
> 'xudc_probe()'
>
> A successful 'clk_prepare_enable()' call should be balanced by a corresponding
> 'clk_disable_unprepare()' call in the error handling path of the probe, as already
> done in the remove function.
>
Reviewed-by: Shubhrajyoti Datta <[email protected]>

> Fixes: 24749229211c ("usb: gadget: udc-xilinx: Add clock support")
> Signed-off-by: Christophe JAILLET <[email protected]>
> ---
> drivers/usb/gadget/udc/udc-xilinx.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/udc/udc-xilinx.c b/drivers/usb/gadget/udc/udc-
> xilinx.c
> index f5ca670776a3..857159dd5ae0 100644
> --- a/drivers/usb/gadget/udc/udc-xilinx.c
> +++ b/drivers/usb/gadget/udc/udc-xilinx.c
> @@ -2136,7 +2136,7 @@ static int xudc_probe(struct platform_device *pdev)
>
> ret = usb_add_gadget_udc(&pdev->dev, &udc->gadget);
> if (ret)
> - goto fail;
> + goto err_disable_unprepare_clk;
>
> udc->dev = &udc->gadget.dev;
>
> @@ -2155,6 +2155,9 @@ static int xudc_probe(struct platform_device *pdev)
> udc->dma_enabled ? "with DMA" : "without DMA");
>
> return 0;
> +
> +err_disable_unprepare_clk:
> + clk_disable_unprepare(udc->clk);
> fail:
> dev_err(&pdev->dev, "probe failed, %d\n", ret);
> return ret;
> --
> 2.30.2