Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F441C7EE2F for ; Thu, 25 May 2023 09:17:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240444AbjEYJRV (ORCPT ); Thu, 25 May 2023 05:17:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240294AbjEYJRS (ORCPT ); Thu, 25 May 2023 05:17:18 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E214A191 for ; Thu, 25 May 2023 02:17:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685006237; x=1716542237; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6aMlAn0mXT9iOdyJQzZq5jHGx+gOFMzw/HjBF3CPNd4=; b=bAX4HSktTvEPh9QQqoYvKgd/ZRsli/IUEI3zjkoVaOhMX2kVGotOoUYD TH7xCLTuohvRl/Kzyt4zqQJaxgjheKrVvrcKL8qgjA17LAAnwXobZqFqw lamW6GakqcH5Luu5xB5mjrfzvC21G970jJu4oiUif1hVaW7SZglEiQtQ0 0weYLBPlp3myNGrAchoGCvNSC++EaXKX1+X44SQ0mwXyFtO+TZg4qounT TgNjs0I+fdp1+SlPXfXVV44wBXWrNgPNjgwARJMf5vG8X/MwjdYM2we/I erDECXQ+6f9b/0S2ZXymjogfQqCMDPM1PVHfmw+CsTNcYa4XvNelwK+CK Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10720"; a="333455831" X-IronPort-AV: E=Sophos;i="6.00,190,1681196400"; d="scan'208";a="333455831" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2023 02:17:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10720"; a="879029126" X-IronPort-AV: E=Sophos;i="6.00,190,1681196400"; d="scan'208";a="879029126" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2023 02:17:10 -0700 Received: from punajuuri.localdomain (punajuuri.localdomain [192.168.240.130]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 6D8AE122FF0; Thu, 25 May 2023 12:16:49 +0300 (EEST) Received: from sailus by punajuuri.localdomain with local (Exim 4.94.2) (envelope-from ) id 1q2758-009kpI-9y; Thu, 25 May 2023 12:16:26 +0300 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, Philipp Zabel , hverkuil@xs4all.nl, Francesco Dolcini , aishwarya.kothari@toradex.com, Robert Foss , Todor Tomov , Hyun Kwon , bingbu.cao@intel.com, niklas.soderlund@ragnatech.se, Kieran Bingham , Benjamin Mugnier , Sylvain Petinot , Eugen Hristev , Nicolas Ferre , Maxime Ripard , Rui Miguel Silva , Fabio Estevam , "Bryan O'Donoghue" , Sylwester Nawrocki , Dafna Hirschfeld , Hugues Fruchet , Yong Deng , Paul Kocialkowski , "Lad, Prabhakar" , Benoit Parrot , Steve Longerbeam , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Marco Felsch Subject: [RESEND PATCH v3 15/32] media: v4l: async: Clean up error handling in v4l2_async_match_notify Date: Thu, 25 May 2023 12:15:58 +0300 Message-Id: <20230525091615.2324824-16-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230525091615.2324824-1-sakari.ailus@linux.intel.com> References: <20230525091615.2324824-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 --- 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); + +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. */ -- 2.30.2