public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-media@vger.kernel.org, Sakari Ailus <sakari.ailus@iki.fi>
Subject: Re: [PATCHv2] adp1653: check error code of adp1653_init_controls
Date: Thu, 28 Jul 2011 16:34:23 +0200	[thread overview]
Message-ID: <201107281634.24288.laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <4db811899ccd7b5315080790a627974e3569c7cc.1311839940.git.andriy.shevchenko@linux.intel.com>

Hi Andy,

On Thursday 28 July 2011 09:59:38 Andy Shevchenko wrote:
> Potentially the adp1653_init_controls could return an error. In our case
> the error was ignored, meanwhile it means incorrect initialization of V4L2
> controls. Additionally we have to free control handler structures in case
> of apd1653_init_controls or media_entity_init failure.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Sakari Ailus <sakari.ailus@iki.fi>
> ---
>  drivers/media/video/adp1653.c |   11 +++++++++--
>  1 files changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/video/adp1653.c b/drivers/media/video/adp1653.c
> index 8ad89ff..279d75d 100644
> --- a/drivers/media/video/adp1653.c
> +++ b/drivers/media/video/adp1653.c
> @@ -429,12 +429,19 @@ static int adp1653_probe(struct i2c_client *client,
>  	flash->subdev.internal_ops = &adp1653_internal_ops;
>  	flash->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
> 
> -	adp1653_init_controls(flash);
> +	ret = adp1653_init_controls(flash);
> +	if (ret)
> +		goto free_and_quit;
> 
>  	ret = media_entity_init(&flash->subdev.entity, 0, NULL, 0);
>  	if (ret < 0)
> -		kfree(flash);
> +		goto free_and_quit;
> 
> +	return 0;
> +
> +free_and_quit:
> +	v4l2_ctrl_handler_free(&flash->ctrls);
> +	kfree(flash);
>  	return ret;

What about

        ret = adp1653_init_controls(flash);
        if (ret)
                goto done;

        ret = media_entity_init(&flash->subdev.entity, 0, NULL, 0);

done:
        if (ret < 0) {
                v4l2_ctrl_handler_free(&flash->ctrls);
                kfree(flash);
        }

        return ret;
>  }

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2011-07-28 14:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-27  7:58 [PATCH] adp1653: check error code of adp1653_init_controls Andy Shevchenko
2011-07-27  8:15 ` Sakari Ailus
2011-07-28  7:55   ` Andy Shevchenko
2011-07-28  7:59   ` [PATCHv2] " Andy Shevchenko
2011-07-28 14:34     ` Laurent Pinchart [this message]
2011-07-29  7:10       ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201107281634.24288.laurent.pinchart@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox