Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5771693rwd; Wed, 24 May 2023 06:39:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4poKT5kLG5TjsjwxTtp7+sQ+pZl5CS9AnxrI1d5XBGQqG6u5h8b5e3ZkEQG5S/t0pCSiwd X-Received: by 2002:a05:6a20:8f07:b0:105:b75e:9df6 with SMTP id b7-20020a056a208f0700b00105b75e9df6mr21404358pzk.26.1684935555888; Wed, 24 May 2023 06:39:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684935555; cv=none; d=google.com; s=arc-20160816; b=c6qUj0ZUAn6Tz/MpkLaFZjbbUxoQGeYYe/ASO61oWBsVhYq4dEGHpmJGMe16m+/YAm tYozVSc0T1Mn5zM/ww/D5o5t2vCR2VpJpnjTNQZ50mEOC0bDp8NTPYMce6SxsiCnlfS9 qXsybPVZj4WP7w8JRkGbsh1WfHu1zF+6+gq2S71FhAZbE5pW+yFi05rlFGgDN0fbzVtD 97Zp/xecG1BGaWE75n9/RSIE0zA32Z7kisQD/0rdORxbWU3uXhLsxJMC20ztpqHt+QLQ fVp1RlWAMIIxeU15uVBXGAanjrX4SG4HjotK0qAhP0FXKtkPOvwzyFb8/Dsdd1OH6u0D mgmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from; bh=4g4GAlDSEsdhQnr6nlPMQ3SSbxX5Y1LgvWjiSOpZiD4=; b=k7fVNuSMLN0sbGEUljTnIfN/2qpcFnqwU0kJfOzVIaIBF785t9K6sOV9ixajM+VqIf N7fuQgLmifzGL5OzczKPGySIpov4PbwZ5DqbrCVVzBuMc3CtMuTni55HxrLen+/Mis+x yhMO5Y1B6EZRZk05AI6zcWEqMjB+rtLKm67SZDI6q5WP2f5axFz9fJNKphyribt7Eb4O JLDOKoWdVnolHVamQVXKklH1hqUpr40C2QkGPE6HkgPEXDRorgpHEb1LJ0bTuZxtAnti 3TbPOfE3h6KI98wMQJK0ewLhnKDLXPuFWqhVRx+1QYl2E9FvNSPf8KD+xnFr7xykIN9w ztsw== ARC-Authentication-Results: i=1; mx.google.com; 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 a15-20020aa794af000000b0064f1f169b61si548463pfl.218.2023.05.24.06.39.01; Wed, 24 May 2023 06:39:15 -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; 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 S234351AbjEXN3g (ORCPT + 99 others); Wed, 24 May 2023 09:29:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230019AbjEXN3f (ORCPT ); Wed, 24 May 2023 09:29:35 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3227AB0 for ; Wed, 24 May 2023 06:29:32 -0700 (PDT) Received: from dude05.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::54]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1q1oYU-0007Bo-HD; Wed, 24 May 2023 15:29:30 +0200 From: Philipp Zabel Date: Wed, 24 May 2023 15:29:24 +0200 Subject: [PATCH 1/2] media: video-mux: fix error paths MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230524-video-mux-active-state-v1-1-325c69937ac3@pengutronix.de> References: <20230524-video-mux-active-state-v1-0-325c69937ac3@pengutronix.de> In-Reply-To: <20230524-video-mux-active-state-v1-0-325c69937ac3@pengutronix.de> To: Mauro Carvalho Chehab Cc: Sakari Ailus , Laurent Pinchart , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de, Philipp Zabel X-Mailer: b4 0.12-dev-aab37 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::54 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 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 --- 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; } -- 2.39.2