From: Sakari Ailus Date: Mon, 17 Apr 2023 14:09:27 +0000 (+0200) Subject: media: v4l: async: Clean up error handling in v4l2_async_match_notify X-Git-Tag: v6.6.7~2014^2~200 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ed59bbe18df09e654ffb18f791f2b47ff59384b1;p=platform%2Fkernel%2Flinux-starfive.git media: v4l: async: Clean up error handling in v4l2_async_match_notify 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 Tested-by: Philipp Zabel # imx6qp Tested-by: Niklas Söderlund # rcar + adv746x Reviewed-by: Laurent Pinchart Tested-by: Aishwarya Kothari # Apalis i.MX6Q with TC358743 Tested-by: Lad Prabhakar # Renesas RZ/G2L SMARC Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index 9964d7f..0a9c9fb 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); + +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. */