Re: [RESEND PATCH v3 15/32] media: v4l: async: Clean up error handling in v4l2_async_match_notify

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

 



Hi Sakari,

Thank you for the patch.

On Thu, May 25, 2023 at 12:15:58PM +0300, Sakari Ailus wrote:
> Add labels for error handling instead of doing it all in individual cases.
> Prepare for more functionality in this function.
> 
> Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
> ---
>  drivers/media/v4l2-core/v4l2-async.c | 21 ++++++++++++---------
>  1 file changed, 12 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
> index b1025dfc27a92..f51f0c37210c9 100644
> --- a/drivers/media/v4l2-core/v4l2-async.c
> +++ b/drivers/media/v4l2-core/v4l2-async.c
> @@ -320,10 +320,8 @@ static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier,
>  		return ret;
>  
>  	ret = v4l2_async_nf_call_bound(notifier, sd, asc);
> -	if (ret < 0) {
> -		v4l2_device_unregister_subdev(sd);
> -		return ret;
> -	}
> +	if (ret < 0)
> +		goto err_unregister_subdev;
>  
>  	/*
>  	 * Depending of the function of the entities involved, we may want to
> @@ -332,11 +330,8 @@ static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier,
>  	 * pad).
>  	 */
>  	ret = v4l2_async_create_ancillary_links(notifier, sd);
> -	if (ret) {
> -		v4l2_async_nf_call_unbind(notifier, sd, asc);
> -		v4l2_device_unregister_subdev(sd);
> -		return ret;
> -	}
> +	if (ret)
> +		goto err_call_unbind;
>  
>  	list_del(&asc->waiting_entry);
>  	sd->asd = asc;
> @@ -363,6 +358,14 @@ static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier,
>  	subdev_notifier->parent = notifier;
>  
>  	return v4l2_async_nf_try_all_subdevs(subdev_notifier);

Unrelated to this patch, but shoulnd't this have error handling too ?

Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@xxxxxxxxxxxxxxxx>

> +
> +err_call_unbind:
> +	v4l2_async_nf_call_unbind(notifier, sd, asc);
> +
> +err_unregister_subdev:
> +	v4l2_device_unregister_subdev(sd);
> +
> +	return ret;
>  }
>  
>  /* Test all async sub-devices in a notifier for a match. */

-- 
Regards,

Laurent Pinchart



[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