diff mbox series

[v2,5/5] media: i2c: imx214: Fix cleanup after controls initialization error

Message ID 20231028-imx214-v2-5-69a8fb730d6e@apitzsch.eu (mailing list archive)
State New, archived
Headers show
Series media: i2c: imx214: Extend with sensor size and firmware information | expand

Commit Message

André Apitzsch Oct. 28, 2023, 7:17 a.m. UTC
If the controls are initialized incorrectly, don't destroy the mutex not
initialized yet and don't free controls as that is handled in
imx214_ctrls_init().

Signed-off-by: André Apitzsch <git@apitzsch.eu>
---
 drivers/media/i2c/imx214.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Ricardo Ribalda Delgado Oct. 28, 2023, 7:30 a.m. UTC | #1
Hi Andre

On Sat, Oct 28, 2023 at 9:19 AM André Apitzsch <git@apitzsch.eu> wrote:
>
> If the controls are initialized incorrectly, don't destroy the mutex not
> initialized yet and don't free controls as that is handled in
> imx214_ctrls_init().
>
> Signed-off-by: André Apitzsch <git@apitzsch.eu>

Since you are calling v4l2_ctrl_handler_free() in imx214_ctrls_init, I
think you should squash this patch with 2/5.

Sorry for asking for a follow-up patch :S

Regards!


> ---
>  drivers/media/i2c/imx214.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c
> index e0d9624a9d3f..0aba28d6dc2f 100644
> --- a/drivers/media/i2c/imx214.c
> +++ b/drivers/media/i2c/imx214.c
> @@ -1069,7 +1069,7 @@ static int imx214_probe(struct i2c_client *client)
>
>         ret = imx214_ctrls_init(imx214);
>         if (ret < 0)
> -               goto free_ctrl;
> +               goto error_power_off;
>
>         mutex_init(&imx214->mutex);
>         imx214->ctrls.lock = &imx214->mutex;
> @@ -1100,6 +1100,7 @@ static int imx214_probe(struct i2c_client *client)
>  free_ctrl:
>         mutex_destroy(&imx214->mutex);
>         v4l2_ctrl_handler_free(&imx214->ctrls);
> +error_power_off:
>         pm_runtime_disable(imx214->dev);
>
>         return ret;
>
> --
> 2.42.0
>
André Apitzsch Oct. 28, 2023, 7:51 a.m. UTC | #2
Hi Ricardo,

Am Samstag, dem 28.10.2023 um 09:30 +0200 schrieb Ricardo Ribalda
Delgado:
> Hi Andre
> 
> On Sat, Oct 28, 2023 at 9:19 AM André Apitzsch <git@apitzsch.eu>
> wrote:
> > 
> > If the controls are initialized incorrectly, don't destroy the
> > mutex not
> > initialized yet and don't free controls as that is handled in
> > imx214_ctrls_init().
> > 
> > Signed-off-by: André Apitzsch <git@apitzsch.eu>
> 
> Since you are calling v4l2_ctrl_handler_free() in imx214_ctrls_init,
> I think you should squash this patch with 2/5.
> 
> Sorry for asking for a follow-up patch :S

I will squash it. Shall I keep the r-b tags?

Is it okay to send the new version now?

> 
> Regards!
> 
> 
> > ---
> >  drivers/media/i2c/imx214.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/media/i2c/imx214.c
> > b/drivers/media/i2c/imx214.c
> > index e0d9624a9d3f..0aba28d6dc2f 100644
> > --- a/drivers/media/i2c/imx214.c
> > +++ b/drivers/media/i2c/imx214.c
> > @@ -1069,7 +1069,7 @@ static int imx214_probe(struct i2c_client
> > *client)
> > 
> >         ret = imx214_ctrls_init(imx214);
> >         if (ret < 0)
> > -               goto free_ctrl;
> > +               goto error_power_off;
> > 
> >         mutex_init(&imx214->mutex);
> >         imx214->ctrls.lock = &imx214->mutex;
> > @@ -1100,6 +1100,7 @@ static int imx214_probe(struct i2c_client
> > *client)
> >  free_ctrl:
> >         mutex_destroy(&imx214->mutex);
> >         v4l2_ctrl_handler_free(&imx214->ctrls);
> > +error_power_off:
> >         pm_runtime_disable(imx214->dev);
> > 
> >         return ret;
> > 
> > --
> > 2.42.0
> >
Ricardo Ribalda Delgado Oct. 28, 2023, 8:12 a.m. UTC | #3
Hi Andre

On Sat, Oct 28, 2023 at 9:51 AM André Apitzsch <git@apitzsch.eu> wrote:
>
> Hi Ricardo,
>
> Am Samstag, dem 28.10.2023 um 09:30 +0200 schrieb Ricardo Ribalda
> Delgado:
> > Hi Andre
> >
> > On Sat, Oct 28, 2023 at 9:19 AM André Apitzsch <git@apitzsch.eu>
> > wrote:
> > >
> > > If the controls are initialized incorrectly, don't destroy the
> > > mutex not
> > > initialized yet and don't free controls as that is handled in
> > > imx214_ctrls_init().
> > >
> > > Signed-off-by: André Apitzsch <git@apitzsch.eu>
> >
> > Since you are calling v4l2_ctrl_handler_free() in imx214_ctrls_init,
> > I think you should squash this patch with 2/5.
> >
> > Sorry for asking for a follow-up patch :S
>
> I will squash it. Shall I keep the r-b tags?

That is ok

>
> Is it okay to send the new version now?

Yes please, thanks :)

>
> >
> > Regards!
> >
> >
> > > ---
> > >  drivers/media/i2c/imx214.c | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/media/i2c/imx214.c
> > > b/drivers/media/i2c/imx214.c
> > > index e0d9624a9d3f..0aba28d6dc2f 100644
> > > --- a/drivers/media/i2c/imx214.c
> > > +++ b/drivers/media/i2c/imx214.c
> > > @@ -1069,7 +1069,7 @@ static int imx214_probe(struct i2c_client
> > > *client)
> > >
> > >         ret = imx214_ctrls_init(imx214);
> > >         if (ret < 0)
> > > -               goto free_ctrl;
> > > +               goto error_power_off;
> > >
> > >         mutex_init(&imx214->mutex);
> > >         imx214->ctrls.lock = &imx214->mutex;
> > > @@ -1100,6 +1100,7 @@ static int imx214_probe(struct i2c_client
> > > *client)
> > >  free_ctrl:
> > >         mutex_destroy(&imx214->mutex);
> > >         v4l2_ctrl_handler_free(&imx214->ctrls);
> > > +error_power_off:
> > >         pm_runtime_disable(imx214->dev);
> > >
> > >         return ret;
> > >
> > > --
> > > 2.42.0
> > >
>
diff mbox series

Patch

diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c
index e0d9624a9d3f..0aba28d6dc2f 100644
--- a/drivers/media/i2c/imx214.c
+++ b/drivers/media/i2c/imx214.c
@@ -1069,7 +1069,7 @@  static int imx214_probe(struct i2c_client *client)
 
 	ret = imx214_ctrls_init(imx214);
 	if (ret < 0)
-		goto free_ctrl;
+		goto error_power_off;
 
 	mutex_init(&imx214->mutex);
 	imx214->ctrls.lock = &imx214->mutex;
@@ -1100,6 +1100,7 @@  static int imx214_probe(struct i2c_client *client)
 free_ctrl:
 	mutex_destroy(&imx214->mutex);
 	v4l2_ctrl_handler_free(&imx214->ctrls);
+error_power_off:
 	pm_runtime_disable(imx214->dev);
 
 	return ret;