[PATCH next] media: raspberrypi: Do some cleanup in probe()

Dan Carpenter posted 1 patch 1 month ago
drivers/media/platform/raspberrypi/rp1-cfe/cfe.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
[PATCH next] media: raspberrypi: Do some cleanup in probe()
Posted by Dan Carpenter 1 month ago
If devm_clk_get() fails then we need to free "cfe" before returning.

Fixes: 6edb685abb2a ("media: raspberrypi: Add support for RP1-CFE")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/media/platform/raspberrypi/rp1-cfe/cfe.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/raspberrypi/rp1-cfe/cfe.c b/drivers/media/platform/raspberrypi/rp1-cfe/cfe.c
index 045910de6c57..1da58b07c1d3 100644
--- a/drivers/media/platform/raspberrypi/rp1-cfe/cfe.c
+++ b/drivers/media/platform/raspberrypi/rp1-cfe/cfe.c
@@ -2343,9 +2343,11 @@ static int cfe_probe(struct platform_device *pdev)
 
 	/* TODO: Enable clock only when running. */
 	cfe->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(cfe->clk))
-		return dev_err_probe(&pdev->dev, PTR_ERR(cfe->clk),
-				     "clock not found\n");
+	if (IS_ERR(cfe->clk)) {
+		ret = dev_err_probe(&pdev->dev, PTR_ERR(cfe->clk),
+				    "clock not found\n");
+		goto err_cfe_put;
+	}
 
 	cfe->mdev.dev = &pdev->dev;
 	cfe->mdev.ops = &cfe_media_device_ops;
-- 
2.45.2
Re: [PATCH next] media: raspberrypi: Do some cleanup in probe()
Posted by Tomi Valkeinen 4 weeks ago
Hi,

On 23/10/2024 11:30, Dan Carpenter wrote:
> If devm_clk_get() fails then we need to free "cfe" before returning.
> 
> Fixes: 6edb685abb2a ("media: raspberrypi: Add support for RP1-CFE")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>   drivers/media/platform/raspberrypi/rp1-cfe/cfe.c | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/platform/raspberrypi/rp1-cfe/cfe.c b/drivers/media/platform/raspberrypi/rp1-cfe/cfe.c
> index 045910de6c57..1da58b07c1d3 100644
> --- a/drivers/media/platform/raspberrypi/rp1-cfe/cfe.c
> +++ b/drivers/media/platform/raspberrypi/rp1-cfe/cfe.c
> @@ -2343,9 +2343,11 @@ static int cfe_probe(struct platform_device *pdev)
>   
>   	/* TODO: Enable clock only when running. */
>   	cfe->clk = devm_clk_get(&pdev->dev, NULL);
> -	if (IS_ERR(cfe->clk))
> -		return dev_err_probe(&pdev->dev, PTR_ERR(cfe->clk),
> -				     "clock not found\n");
> +	if (IS_ERR(cfe->clk)) {
> +		ret = dev_err_probe(&pdev->dev, PTR_ERR(cfe->clk),
> +				    "clock not found\n");
> +		goto err_cfe_put;
> +	}
>   
>   	cfe->mdev.dev = &pdev->dev;
>   	cfe->mdev.ops = &cfe_media_device_ops;

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

  Tomi