[PATCH] media: i2c: max96717: clean up on error in max96717_subdev_init()

Dan Carpenter posted 1 patch 2 months, 2 weeks ago
There is a newer version of this series
drivers/media/i2c/max96717.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
[PATCH] media: i2c: max96717: clean up on error in max96717_subdev_init()
Posted by Dan Carpenter 2 months, 2 weeks ago
Call v4l2_ctrl_handler_free() to clean up from v4l2_ctrl_handler_init().

Fixes: 50f222455793 ("media: i2c: add MAX96717 driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
From static analysis.  Not tested.

 drivers/media/i2c/max96717.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/max96717.c b/drivers/media/i2c/max96717.c
index 4e85b8eb1e77..9259d58ba734 100644
--- a/drivers/media/i2c/max96717.c
+++ b/drivers/media/i2c/max96717.c
@@ -697,8 +697,10 @@ static int max96717_subdev_init(struct max96717_priv *priv)
 	priv->pads[MAX96717_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
 
 	ret = media_entity_pads_init(&priv->sd.entity, 2, priv->pads);
-	if (ret)
-		return dev_err_probe(dev, ret, "Failed to init pads\n");
+	if (ret) {
+		dev_err_probe(dev, ret, "Failed to init pads\n");
+		goto err_free_ctrl;
+	}
 
 	ret = v4l2_subdev_init_finalize(&priv->sd);
 	if (ret) {
-- 
2.45.2
Re: [PATCH] media: i2c: max96717: clean up on error in max96717_subdev_init()
Posted by Julien Massot 2 months ago
Hi,
On Thu, 2024-09-12 at 11:51 +0300, Dan Carpenter wrote:
> Call v4l2_ctrl_handler_free() to clean up from
> v4l2_ctrl_handler_init().
> 
> Fixes: 50f222455793 ("media: i2c: add MAX96717 driver")

The right commit to fix is:
Fixes: 19b5e5511ca4f ("media: i2c: max96717: add test pattern ctrl")

Since there was no control to free in the initial driver.

Reviewed-by: Julien Massot <julien.massot@collabora.com>

Regards,
Julien

> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> From static analysis.  Not tested.
> 
>  drivers/media/i2c/max96717.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/i2c/max96717.c
> b/drivers/media/i2c/max96717.c
> index 4e85b8eb1e77..9259d58ba734 100644
> --- a/drivers/media/i2c/max96717.c
> +++ b/drivers/media/i2c/max96717.c
> @@ -697,8 +697,10 @@ static int max96717_subdev_init(struct
> max96717_priv *priv)
>  	priv->pads[MAX96717_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
>  
>  	ret = media_entity_pads_init(&priv->sd.entity, 2, priv-
> >pads);
> -	if (ret)
> -		return dev_err_probe(dev, ret, "Failed to init
> pads\n");
> +	if (ret) {
> +		dev_err_probe(dev, ret, "Failed to init pads\n");
> +		goto err_free_ctrl;
> +	}
>  
>  	ret = v4l2_subdev_init_finalize(&priv->sd);
>  	if (ret) {

-- 
-- 
Julien Massot
Senior Software Engineer
Collabora Ltd.
Platinum Building, St John's Innovation Park, Cambridge CB4 0DS, UK
Registered in England & Wales, no. 5513718
Re: [PATCH] media: i2c: max96717: clean up on error in max96717_subdev_init()
Posted by Dan Carpenter 2 months ago
On Fri, Sep 27, 2024 at 12:47:03PM +0200, Julien Massot wrote:
> Hi,
> On Thu, 2024-09-12 at 11:51 +0300, Dan Carpenter wrote:
> > Call v4l2_ctrl_handler_free() to clean up from
> > v4l2_ctrl_handler_init().
> > 
> > Fixes: 50f222455793 ("media: i2c: add MAX96717 driver")
> 
> The right commit to fix is:
> Fixes: 19b5e5511ca4f ("media: i2c: max96717: add test pattern ctrl")
> 
> Since there was no control to free in the initial driver.
> 
> Reviewed-by: Julien Massot <julien.massot@collabora.com>
> 

Yep.  You're right.  That makes more sense.  I'll resend.

regards,
dan carpenter