Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4793420rwd; Tue, 30 May 2023 09:58:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5B9HibZTUG3vIfLn5mj0+siZa2H/61wCaPONk7jWr9M5Q85s0Gx7+2M3TVpXs4e6x8zLpq X-Received: by 2002:a17:902:8f8b:b0:1a9:21bc:65f8 with SMTP id z11-20020a1709028f8b00b001a921bc65f8mr2460904plo.11.1685465909294; Tue, 30 May 2023 09:58:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685465909; cv=none; d=google.com; s=arc-20160816; b=LubENX32G1mAzM3zHyD+wG6SjPVRwd+pPf/VsAez9Oe4YkVJfpEzq5sFMUX0gb+tbu X2tyFJLJkIG1dKtOhbKwvfLyN7lm3TgC1kXLXVXY3SW952UyJa+acbgn19KPOZj0oabx oN2IiH8rTYjr2oblNqTu1Ojg4H0EG7LNvjZbXhhEihQStJZi80K4T95s+BoLiXuokm3z V9M++x8V34lbvXkpznIXz/DiLKpaVeh7UhL0ykFC9mShmXXJ3uQlJ9Ck1MJbx049VcdB f03ZnVzdSF7hV4GTSIAkv9BsdY2dqITMHgoeDwf631Wsj9TlT6D1C0sDgw7T+h4Ns0XU JN1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=QXD8a/v/NrbjorbN3VsAAcUjza3B1zsMHNcUWrW0tJo=; b=iP9yCTDOMs/xcC0fB96hD3RE9fjQxraMfXoZhT/v4YW1nbZ3GjMzlFVKUacbp+CHEN rC1+iCmgcPnRG5IqOHhPRH+HBuvBRVnsT3Q9m+gyZ08hRdHnbsFcaP0Mi5oXJpXdAMSG KFStdL4WttIer9IgQ+KPiB5WM5jBRmM9sdAsF/+NRpGh94tcBYy7CXUoH8t3V3HtAfOs Ec1Tj8ayNy0RMJtKUbkwFAV+De3tjQfH51MPXvmgPzoCpXFsG91XZlQ8Spw4tXQkeM1g iqlOdN8pjMlR/up9tSXkJ39U4qOZODysXoK8aAZB4Fprcj+luEW1RWQ07CS+lec5wpjm a+PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=jiPzPo9a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 6-20020a170902c24600b001adf26b357bsi11039183plg.631.2023.05.30.09.58.17; Tue, 30 May 2023 09:58:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=jiPzPo9a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231618AbjE3QrR (ORCPT + 99 others); Tue, 30 May 2023 12:47:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229673AbjE3QrQ (ORCPT ); Tue, 30 May 2023 12:47:16 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F01FF9D; Tue, 30 May 2023 09:47:14 -0700 (PDT) Received: from pendragon.ideasonboard.com (om126205198071.34.openmobile.ne.jp [126.205.198.71]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 797077EC; Tue, 30 May 2023 18:46:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1685465212; bh=b1FpUfw+Soo2stZMK535cATzI69cCENayvLuTSQl0Xk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jiPzPo9a/9eNF7A2JfrmSmdtLTpMHGuvqYe2SmywfzLh2CAt9+wE0vIOA2MFqqMnv nGnQjmJtzVbL3YZqQAA16RQpa05x3JhB1Jfi82+1U71aqKRcOQX3S3Z5Ig9dgsMrYq bNpiQtGYQ/IxlqQe2i8+kl4BdnzPryMIFRK/3174= Date: Tue, 30 May 2023 19:47:12 +0300 From: Laurent Pinchart To: Philipp Zabel Cc: Mauro Carvalho Chehab , Sakari Ailus , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de Subject: Re: [PATCH 1/2] media: video-mux: fix error paths Message-ID: <20230530164712.GB22516@pendragon.ideasonboard.com> References: <20230524-video-mux-active-state-v1-0-325c69937ac3@pengutronix.de> <20230524-video-mux-active-state-v1-1-325c69937ac3@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230524-video-mux-active-state-v1-1-325c69937ac3@pengutronix.de> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Philipp, Thank you for the patch. On Wed, May 24, 2023 at 03:29:24PM +0200, Philipp Zabel wrote: > Move notifier cleanup into video_mux_async_register() to avoid calling > v4l2_async_nf_unregister() when v4l2_async_subdev_nf_register() failed. > In case video_mux_async_register() fails, call media_entity_cleanup(). > > Signed-off-by: Philipp Zabel Reviewed-by: Laurent Pinchart > --- > drivers/media/platform/video-mux.c | 26 +++++++++++++++++++------- > 1 file changed, 19 insertions(+), 7 deletions(-) > > diff --git a/drivers/media/platform/video-mux.c b/drivers/media/platform/video-mux.c > index 1d9f32e5a917..4fe31386afc7 100644 > --- a/drivers/media/platform/video-mux.c > +++ b/drivers/media/platform/video-mux.c > @@ -389,7 +389,7 @@ static int video_mux_async_register(struct video_mux *vmux, > ret = PTR_ERR(asd); > /* OK if asd already exists */ > if (ret != -EEXIST) > - return ret; > + goto err_nf_cleanup; > } > } > > @@ -397,9 +397,19 @@ static int video_mux_async_register(struct video_mux *vmux, > > ret = v4l2_async_subdev_nf_register(&vmux->subdev, &vmux->notifier); > if (ret) > - return ret; > + goto err_nf_cleanup; > > - return v4l2_async_register_subdev(&vmux->subdev); > + ret = v4l2_async_register_subdev(&vmux->subdev); > + if (ret) > + goto err_nf_unregister; > + > + return 0; > + > +err_nf_unregister: > + v4l2_async_nf_unregister(&vmux->notifier); > +err_nf_cleanup: > + v4l2_async_nf_cleanup(&vmux->notifier); > + return ret; > } > > static int video_mux_probe(struct platform_device *pdev) > @@ -473,11 +483,13 @@ static int video_mux_probe(struct platform_device *pdev) > vmux->subdev.entity.ops = &video_mux_ops; > > ret = video_mux_async_register(vmux, num_pads - 1); > - if (ret) { > - v4l2_async_nf_unregister(&vmux->notifier); > - v4l2_async_nf_cleanup(&vmux->notifier); > - } > + if (ret) > + goto err_entity_cleanup; > > + return 0; > + > +err_entity_cleanup: > + media_entity_cleanup(&vmux->subdev.entity); > return ret; > } > > -- Regards, Laurent Pinchart