Re: [PATCH 6/9] as3645a: free resources in case of error properly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Andy,

Thanks for the patch.

On Tuesday 15 November 2011 18:49:58 Andy Shevchenko wrote:
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> ---
>  drivers/media/video/as3645a.c |   23 ++++++++++++-----------
>  1 files changed, 12 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/media/video/as3645a.c b/drivers/media/video/as3645a.c
> index 541f8bc..9aebaa2 100644
> --- a/drivers/media/video/as3645a.c
> +++ b/drivers/media/video/as3645a.c
> @@ -800,11 +800,13 @@ static int as3645a_probe(struct i2c_client *client,
>  	flash->subdev.internal_ops = &as3645a_internal_ops;
>  	flash->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
> 
> +	ret = as3645a_init_controls(flash);
> +	if (ret < 0)
> +		goto free_and_quit;
> +
>  	ret = media_entity_init(&flash->subdev.entity, 0, NULL, 0);
> -	if (ret < 0) {
> -		kfree(flash);
> -		return ret;
> -	}
> +	if (ret < 0)
> +		goto free_and_quit;
> 
>  	flash->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
> 
> @@ -812,13 +814,12 @@ static int as3645a_probe(struct i2c_client *client,
> 
>  	flash->led_mode = V4L2_FLASH_LED_MODE_NONE;
> 
> -	ret = as3645a_init_controls(flash);
> -	if (ret < 0) {
> -		kfree(flash);
> -		return ret;
> -	}
> -

Would you mind if I replace this code below

>  	return 0;
> +
> +free_and_quit:
> +	v4l2_ctrl_handler_free(&flash->ctrls);
> +	kfree(flash);
> +	return ret;

with

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

	return ret;

>  }
> 
>  static int __exit as3645a_remove(struct i2c_client *client)
> @@ -828,7 +829,7 @@ static int __exit as3645a_remove(struct i2c_client
> *client)
> 
>  	v4l2_device_unregister_subdev(subdev);
>  	v4l2_ctrl_handler_free(&flash->ctrls);
> -
> +	media_entity_cleanup(&flash->subdev.entity);
>  	kfree(flash);
> 
>  	return 0;

-- 
Regards,

Laurent Pinchart
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux