Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5881256rwb; Tue, 1 Aug 2023 09:07:06 -0700 (PDT) X-Google-Smtp-Source: APBJJlHINRAzQtF9uer0DxJCoe5WHRRrvuo1fC8SNY4Z32QAk4lZAqrBYjSxYTkCLAaJFvtS0BFk X-Received: by 2002:a05:6a00:a21:b0:687:1527:e5bc with SMTP id p33-20020a056a000a2100b006871527e5bcmr13448737pfh.29.1690906026088; Tue, 01 Aug 2023 09:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690906026; cv=none; d=google.com; s=arc-20160816; b=t4I3XcvG3oMFEckoOvmhDo1KwjhvlogmI6MYY5qYNKUjymegoUSQwOIUaWZJVqpkOI fEv5oQvMsCs2DoIUAGUGKV0sifBVMpDPDjYmHJx3Woq34mrbgQ2IDMbIEPP4E1Mi6ZBN r7gn/BosCL6k4Jq//K7JkAJpjqhktkOgY1xmx/NfZmddalSPEEKxCh7GPBEl6fQ4BMXN knuKThOrLCCodTQUqSQdGjR7n1NQVcqaLwPD840UYHFG+fBPmHQ7OmUp9m804Z3iZbU3 9kiRKKfYEv8slgwq1XhKMEtnpZRd4HK22yqJZfw/OUTOJbIpVO6fGF8FXD/D2tRZy1/R 5PGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=1Z8GGfBLOENsrwgc2Rrfhl01dN+5ksJ61Pa0P4CZpcA=; fh=LroA/i1EM0DOjWSTFbQc0E4XLyK+5NHY20upRsJ5XaQ=; b=xlX1zjEmAzLC5prKOjZW1SYC/jG5xL4ZlWyLOX8QFF5VBoiVRSOoNxn4an/li8o939 h0bBFrZx89p2lWRsfaFjGrbq+qETCzElRFWOIlLlVXTRNcqfABwM30ftIUXxEhgjECsF UeihinKhyXWM5HkFMkkH72WDMdpYoO3MeipSZaTOHBm7Mkr+LjNzv5/bxl3A3V51PxIZ y3vtpcPZTBNLhmlNxsU2uOEQ+9i9MUOjLY8zfovFDLWMDMl/J2PHE26w53mKxiwt2hql v2CXEhcxIBAoGDRod9DXXbtzwwdYNWMpTt1Xt7ozQoex0VuRum7LeSqPsZjlxo6Rs9Up cIxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=lxBIyPp4; 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 a126-20020a636684000000b00563a0bacbb4si4264715pgc.694.2023.08.01.09.06.42; Tue, 01 Aug 2023 09:07:06 -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=lxBIyPp4; 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 S233710AbjHAOLS (ORCPT + 99 others); Tue, 1 Aug 2023 10:11:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232972AbjHAOLP (ORCPT ); Tue, 1 Aug 2023 10:11:15 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C35221B7; Tue, 1 Aug 2023 07:11:13 -0700 (PDT) Received: from [192.168.88.20] (91-154-35-171.elisa-laajakaista.fi [91.154.35.171]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id ADEC93D4; Tue, 1 Aug 2023 16:10:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1690899009; bh=N7PpNEg1z3VbAPOM3ThI7rYhCHNOb2LDfb+3MxgePyc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=lxBIyPp4JjdrgIfBC02WdMrYg8FUeQ4dIfybGMRkpoSqvqqu9+VMGHPUTJiu/E2kH /zWqVKv4+DZSC107wWZyJaR4eubaRhfvGIawV03ktZZB2XN1d2x5DzQjwm3NyQzJdJ ZFz2JARtQTzM4gFrBhsARqzzQNMmHjOpu1bsBiM0= Message-ID: <68ad27c8-859e-bb3f-7879-26cf5f1fcfbc@ideasonboard.com> Date: Tue, 1 Aug 2023 17:11:09 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v8 05/16] media: cadence: csi2rx: Unregister v4l2 async notifier Content-Language: en-US To: Jai Luthra , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Laurent Pinchart Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Mauro Carvalho Chehab , Maxime Ripard , niklas.soderlund+renesas@ragnatech.se, Benoit Parrot , Vaishnav Achath , Vignesh Raghavendra , nm@ti.com, devarsht@ti.com References: <20230731-upstream_csi-v8-0-fb7d3661c2c9@ti.com> <20230731-upstream_csi-v8-5-fb7d3661c2c9@ti.com> From: Tomi Valkeinen In-Reply-To: <20230731-upstream_csi-v8-5-fb7d3661c2c9@ti.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,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 On 31/07/2023 11:29, Jai Luthra wrote: > From: Pratyush Yadav > > The notifier is added to the global notifier list when registered. When > the module is removed, the struct csi2rx_priv in which the notifier is > embedded, is destroyed. As a result the notifier list has a reference to > a notifier that no longer exists. This causes invalid memory accesses > when the list is iterated over. Similar for when the probe fails. > Unregister and clean up the notifier to avoid this. > > Fixes: 1fc3b37f34f6 ("media: v4l: cadence: Add Cadence MIPI-CSI2 RX driver") > > Signed-off-by: Pratyush Yadav > Signed-off-by: Jai Luthra > Reviewed-by: Laurent Pinchart > --- > v7->v8: No change > > drivers/media/platform/cadence/cdns-csi2rx.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c > index b087583d636f..fd6f2e04e77f 100644 > --- a/drivers/media/platform/cadence/cdns-csi2rx.c > +++ b/drivers/media/platform/cadence/cdns-csi2rx.c > @@ -479,8 +479,10 @@ static int csi2rx_parse_dt(struct csi2rx_priv *csi2rx) > asd = v4l2_async_nf_add_fwnode_remote(&csi2rx->notifier, fwh, > struct v4l2_async_connection); > of_node_put(ep); > - if (IS_ERR(asd)) > + if (IS_ERR(asd)) { > + v4l2_async_nf_cleanup(&csi2rx->notifier); > return PTR_ERR(asd); > + } > > csi2rx->notifier.ops = &csi2rx_notifier_ops; > > @@ -543,6 +545,7 @@ static int csi2rx_probe(struct platform_device *pdev) > return 0; > > err_cleanup: > + v4l2_async_nf_unregister(&csi2rx->notifier); > v4l2_async_nf_cleanup(&csi2rx->notifier); > err_free_priv: > kfree(csi2rx); > @@ -553,6 +556,8 @@ static void csi2rx_remove(struct platform_device *pdev) > { > struct csi2rx_priv *csi2rx = platform_get_drvdata(pdev); > > + v4l2_async_nf_unregister(&csi2rx->notifier); > + v4l2_async_nf_cleanup(&csi2rx->notifier); > v4l2_async_unregister_subdev(&csi2rx->subdev); > kfree(csi2rx); > } > Reviewed-by: Tomi Valkeinen Tomi