From patchwork Thu Oct 19 07:35:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 155347 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp217207vqb; Thu, 19 Oct 2023 00:37:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE439l+mfPr4fotaMbZqyH7wwbxP9zLswci/4MRQQ7gPJ+mjmpbAwGQXggUUZTseLl73aOC X-Received: by 2002:a05:6830:2693:b0:6b5:ee8f:73af with SMTP id l19-20020a056830269300b006b5ee8f73afmr1732091otu.5.1697701043175; Thu, 19 Oct 2023 00:37:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697701043; cv=none; d=google.com; s=arc-20160816; b=WeoGPrpBcFQnfHdBJw7nnhMY9cTA0N1kNWEycuMlDjsQCYgsORe9GRW02prCi//LdA yLVeNAF3hLOyUR58mnJvF7x+sQfalPACq3SGfViv/albZ4ux2j0WB3PD9PiJbcL8JaN1 DxA6S0STycCLdM0FqQ7ey13tyrUtaCUImPQ+N0Oqu2kamZhJVKeAfnnoU3Lv0LlJehCu 8LbeEZrgJd0DiMo4E9ug76w+vfhCfkQj2fn5NNEiN8Jo8QKvNuD+ImU+XXqEmXOrJ4pB JEqlJ+KmbmUNEArIKk/F03tYws1AVVSOKrhxlvdD6JPZh5+AyABNKrD3W6HCEDVeGjVm 0NZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VljKvcZf/EXnYo0tKS/DyDEGs7c3doXtHpGuUWARKus=; fh=vOhmkbio3vldgRDpkNvRPbxSZ54ZZOuVH6tekc4/rDo=; b=SFwk9HHBWAnOb5Jqw/r3SK57Qvym0dt8nfzxWG3fWM8pZf2IGMmUAz8irQH615m7zi nqZZDohyuJQXWnYHsDplC3avUJ6aat84RihDIIgTU7+9ZbALSn104pjFv1G9W+CAnvHI nKAVGEpNgWr8LqH8myDwkmW3Swg0rneBDF9cz6qMOTx5nst+ApN0iIPgYGCPmv7nEV+l koFD6xpxHuuzbAz280K3D2H9YT1XHEJYojJo/CIyyK3L2VuJ/RUQDhCuDJbhrkDJycyU 12PrT3zXeKs3UNbpgVhiBOioFm58PwLX+EHtVy03o2ckEL8jVmAvlgbrLZYT5lqGKE3r qMUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=TnGO04pl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id fa40-20020a056a002d2800b0068fdfe29f0asi5803138pfb.88.2023.10.19.00.37.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 00:37:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=TnGO04pl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 0C02D80A58CE; Thu, 19 Oct 2023 00:36:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235202AbjJSHfz (ORCPT + 24 others); Thu, 19 Oct 2023 03:35:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232740AbjJSHfp (ORCPT ); Thu, 19 Oct 2023 03:35:45 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E851123; Thu, 19 Oct 2023 00:35:39 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPA id B29E460015; Thu, 19 Oct 2023 07:35:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697700938; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VljKvcZf/EXnYo0tKS/DyDEGs7c3doXtHpGuUWARKus=; b=TnGO04pllN2NdXN8HvmX5Ctmryt7kpBynSUXqeKzaKMbLJqBcYTmT+EZSR5fdav2iKFd89 T8M/NYGVRxeJ3W2eWtlNX94F7P4F6VhOCfasDtJLsZCNfeBG0mVgnP7E3xKWS3uvivyjG6 B1P6bEe4XlpGTrKQ4F/WWnRmCQRjvXQ/cuPuq3ccwaL7VEPipuW+e3ScGSKIdWxKpnjvz6 KrUDWW2tsrhad9MbkUlCH2JpPz+tnq83WGPcLRMeV/Dketbb8G8ezzPR+kedMDISV+Nmv2 TgiNszAXGbrmA+s/4qKQhZ+FvMQfUPjlFBCQuei5S5gAtlpdMITwBvVPdJkJ7g== From: Herve Codina To: Wolfram Sang , Peter Rosin Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Allan Nielsen , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni , Herve Codina Subject: [PATCH 1/3] i2c: muxes: i2c-mux-pinctrl: Use of_get_i2c_adapter_by_node() Date: Thu, 19 Oct 2023 09:35:28 +0200 Message-ID: <20231019073533.386563-2-herve.codina@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231019073533.386563-1-herve.codina@bootlin.com> References: <20231019073533.386563-1-herve.codina@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: herve.codina@bootlin.com X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 19 Oct 2023 00:36:09 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780168568849595388 X-GMAIL-MSGID: 1780168568849595388 i2c-mux-pinctrl uses the pair of_find_i2c_adapter_by_node() / i2c_put_adapter(). These pair alone is not correct to properly lock the I2C parent adapter. Indeed, i2c_put_adapter() decrements the module refcount while of_find_i2c_adapter_by_node() does not increment it. This leads to an overflow over zero of the parent adapter user counter. Use the dedicated function, of_get_i2c_adapter_by_node(), to handle correctly the module refcount. Signed-off-by: Herve Codina Acked-by: Peter Rosin --- drivers/i2c/muxes/i2c-mux-pinctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/muxes/i2c-mux-pinctrl.c b/drivers/i2c/muxes/i2c-mux-pinctrl.c index 18236b9fa14a..6ebca7bfd8a2 100644 --- a/drivers/i2c/muxes/i2c-mux-pinctrl.c +++ b/drivers/i2c/muxes/i2c-mux-pinctrl.c @@ -62,7 +62,7 @@ static struct i2c_adapter *i2c_mux_pinctrl_parent_adapter(struct device *dev) dev_err(dev, "Cannot parse i2c-parent\n"); return ERR_PTR(-ENODEV); } - parent = of_find_i2c_adapter_by_node(parent_np); + parent = of_get_i2c_adapter_by_node(parent_np); of_node_put(parent_np); if (!parent) return ERR_PTR(-EPROBE_DEFER); From patchwork Thu Oct 19 07:35:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 155346 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp216864vqb; Thu, 19 Oct 2023 00:36:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFVO7jU2TN6JHm2ktVvvRabepsp6jSmGPqWUVP1VlJEouho+Uo6MieD03b1t4y3Ag4zCbif X-Received: by 2002:a05:6870:7f11:b0:1d6:97:bd7d with SMTP id xa17-20020a0568707f1100b001d60097bd7dmr1657608oab.34.1697700981782; Thu, 19 Oct 2023 00:36:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697700981; cv=none; d=google.com; s=arc-20160816; b=WSUOFd42d+jk5HyOG14JSl7UQfihk/d2l8fCL89FDN68UulKVYwJk5xXQp58UBgMpf tsfF46jt4veODmqc6+nfKTYeB+yH6DH/gKoXIix/z9IkwrCrCzMRWdAtQwizovQwSE5p xkzLOhWdcRGWHgj9b3vORfHyZr1relCdo1WGuQpMrsKjAQ4+IvCGlx+cTpbWCPYHGlC/ sknc55jLQx5xMfAoCXBQLWk/YT6usGsph3+xwpRqkRyupBXlD8tsWzx0RmFUUb2GGX8J bNTgzCvsFOH/CH6hYqvbGUxYxq19mWr8Jj4jgv6q2bIvR6j86Ze9+9ZZEP+ZXktQqvng So2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1zQQWSz04/H2hag4Q35KvlhhCVC0O8O6ITBzwolUSNM=; fh=vOhmkbio3vldgRDpkNvRPbxSZ54ZZOuVH6tekc4/rDo=; b=YOueBdPRr6DTWCi6zFymR5t/Z7EnSnTpgq6c80ZJsChV196Jpf3+iupJTW7y0m6xRb GyqjXDew/38hG5/pNMmQ4UxpkziX6ytDEXXgg5OEJ0jfBSz8+ZU0kA2/YQFngXoDEqj5 W+qF5XTaMjhBpgUuGNgEnDoKUtbKFRk482cF5sNBMMykZlasTdGLhHatpGDDQ4qd/6xW OFIlgosFyqm06Bw3IsFeVIcDtqLk5gfVy0GDkPlXnM4tAKPyewZIzvsqlSaGUTnz7eIs GAFRDCl45Lub+dapy+V7bWZOo46HFiNFUBkTrXYHCb+5Hv7wRn+knJVu3zxaY3yrEGgW b3KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=iuhHAcND; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id 138-20020a630090000000b005abf640eec5si4141103pga.171.2023.10.19.00.36.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 00:36:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=iuhHAcND; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id CC2D68022AB6; Thu, 19 Oct 2023 00:36:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235146AbjJSHfw (ORCPT + 24 others); Thu, 19 Oct 2023 03:35:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232850AbjJSHfp (ORCPT ); Thu, 19 Oct 2023 03:35:45 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9C71124; Thu, 19 Oct 2023 00:35:40 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPA id CA4EA60006; Thu, 19 Oct 2023 07:35:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697700939; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1zQQWSz04/H2hag4Q35KvlhhCVC0O8O6ITBzwolUSNM=; b=iuhHAcNDyvddfFaZuGzZHyiaiWXS4ys9awfpHqiO2zEYJFhBdjCL9lwwFMqElgBEfAHVgF 6+NIQSMrvfcYWDgTRlGR+KMWQJal1sJFTIx6TUzJSDhnvL1K10gH5zzQX0/K1Hkgf/MDce PlrMSoqdS5TN3Kp6QA958aCngepeRrZZVmzMC1BI2OSlX6bYaVtA0dRCldvPXWvOVanQNd 5cRun6hFE3JuneLw7AlWPms7y05Z9yFwvmMh3nrkwDqfgQTGpq94HfVIXHMYMKlXFeIKJH 4A32YP8haFtSPwgm8Cv56QWL5NMwz40nO3Dk2y95dTtdKyXCYTHtsuwPwZ1RiA== From: Herve Codina To: Wolfram Sang , Peter Rosin Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Allan Nielsen , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni , Herve Codina Subject: [PATCH 2/3] i2c: muxes: i2c-demux-pinctrl: Use of_get_i2c_adapter_by_node() Date: Thu, 19 Oct 2023 09:35:29 +0200 Message-ID: <20231019073533.386563-3-herve.codina@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231019073533.386563-1-herve.codina@bootlin.com> References: <20231019073533.386563-1-herve.codina@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: herve.codina@bootlin.com X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 19 Oct 2023 00:36:16 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780168504585849465 X-GMAIL-MSGID: 1780168504585849465 i2c-demux-pinctrl uses the pair of_find_i2c_adapter_by_node() / i2c_put_adapter(). These pair alone is not correct to properly lock the I2C parent adapter. Indeed, i2c_put_adapter() decrements the module refcount while of_find_i2c_adapter_by_node() does not increment it. This leads to an overflow over zero of the parent adapter user counter. Use the dedicated function, of_get_i2c_adapter_by_node(), to handle correctly the module refcount. Signed-off-by: Herve Codina Acked-by: Peter Rosin --- drivers/i2c/muxes/i2c-demux-pinctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/muxes/i2c-demux-pinctrl.c b/drivers/i2c/muxes/i2c-demux-pinctrl.c index 22f2280eab7f..9f2e4aa28159 100644 --- a/drivers/i2c/muxes/i2c-demux-pinctrl.c +++ b/drivers/i2c/muxes/i2c-demux-pinctrl.c @@ -61,7 +61,7 @@ static int i2c_demux_activate_master(struct i2c_demux_pinctrl_priv *priv, u32 ne if (ret) goto err; - adap = of_find_i2c_adapter_by_node(priv->chan[new_chan].parent_np); + adap = of_get_i2c_adapter_by_node(priv->chan[new_chan].parent_np); if (!adap) { ret = -ENODEV; goto err_with_revert; From patchwork Thu Oct 19 07:35:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 155348 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp217216vqb; Thu, 19 Oct 2023 00:37:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEJ0Ga9uS9QQ1e3NMEWwSrR0Ck0v+/cT6vjdqAw5bwz2+hc/y/9qkF2pBN5v50Ltg34PeU/ X-Received: by 2002:a05:6870:d87:b0:1ea:137:7dba with SMTP id mj7-20020a0568700d8700b001ea01377dbamr1682672oab.10.1697701043993; Thu, 19 Oct 2023 00:37:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697701043; cv=none; d=google.com; s=arc-20160816; b=rjsveI1S+dEVmwyvI93SP1IyuYxl881beA/q4TCE6eOfDxfbMynBYko4R48DekZ4Q1 E6O0N1uI0FC3/ZTJgt3Hg2a2iqlU8mMzZFZPnIduj5qC+yJIWXGM3VHOvPCK6Fb6g5ND JBUQCOG2c39hEGgd0yPzy0/KSjLQZGH1VAgneOEmAnEIhxKHPD9a3i4XVg15hbigTClF KXKhSVUr1yTlCQQjvhH9LOAzJIzJX2BqiLPaY2koGQAYBLbROCz6n6oO/1IxADcVO+vh 4E6ufYEtqazbREKM9qPr4sQcCi1A1KOcghMeDxxOGXJYnurXjb1rl2KhFHwLgeHCrPD2 hBZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wFxDhOHA1nOXegi4jc03C6n7+wwkMRGPrbKDfHusrSk=; fh=vOhmkbio3vldgRDpkNvRPbxSZ54ZZOuVH6tekc4/rDo=; b=jzzcN4TCyBV/cK7zxiqiVgDQDJIsa1thZakBORnI2FFejJektHJb/21T8fbp5Ws1NL unOzObUZv8B2WjtUcg1Af4T/2Ti5GwXQpo2xLMearQV56GLWcp3IPzu+9HC2s1bNQxjD EsVM77gZGkjO9QUf6ezAg/TzbqDBkA7MikLVO1lZORCQ/caZ6Z1ydeNI6z0oAvfZm746 Yh9g6Jf/f5h9J7SIJUGd6Vm9N+N23i9XzF6tb6rZTGkec7P8ThkvDRNfpbVgfU3LAVi9 QWNafmqBdTNt5v5I/U2IYZAgOkML8PREctupoHWMt0JqwT6kk/HqkWQlMs8zVyfz4WEN Ay8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=oIZDd51e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id t64-20020a638143000000b00578bab760desi3792547pgd.278.2023.10.19.00.37.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 00:37:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=oIZDd51e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 45F688057DB4; Thu, 19 Oct 2023 00:36:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235060AbjJSHft (ORCPT + 24 others); Thu, 19 Oct 2023 03:35:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232810AbjJSHfo (ORCPT ); Thu, 19 Oct 2023 03:35:44 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFBE4126; Thu, 19 Oct 2023 00:35:41 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPA id BECF76001A; Thu, 19 Oct 2023 07:35:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697700940; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wFxDhOHA1nOXegi4jc03C6n7+wwkMRGPrbKDfHusrSk=; b=oIZDd51e4WPDovOewLVpzqon29hf6yqKMU4ml/UupSHOM0hr7uGRWapYHOWcoPUh+AYRcp RoYh6KyVzV+fFk/c5u/5uvEPAT90V1hu2D00E1ftPqL8bHD04k8PnE362UOfYH+GLwcVkD +99+4hRHNILhBrp2RWIyD7TTu3RXLj5n46D4XaW0RdTp+Lip8i7c3Kba12b9US1a2hiWp7 WneLhRMx+9AQEWl/f921YBMV5bEx/P+jMwKFOb5iHyXgj4ZvhM4aLW+XqtMvXTQSNILcTl yl2aqUvlAQASPzCBmD2UQX/WKxDekAaFEG8L1ZnGAga5zCB8rm/uR6pU7E7NaQ== From: Herve Codina To: Wolfram Sang , Peter Rosin Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Allan Nielsen , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni , Herve Codina Subject: [PATCH 3/3] i2c: muxes: i2c-mux-gpmux: Use of_get_i2c_adapter_by_node() Date: Thu, 19 Oct 2023 09:35:30 +0200 Message-ID: <20231019073533.386563-4-herve.codina@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231019073533.386563-1-herve.codina@bootlin.com> References: <20231019073533.386563-1-herve.codina@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: herve.codina@bootlin.com X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 19 Oct 2023 00:36:26 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780168569687147305 X-GMAIL-MSGID: 1780168569687147305 i2c-mux-gpmux uses the pair of_find_i2c_adapter_by_node() / i2c_put_adapter(). These pair alone is not correct to properly lock the I2C parent adapter. Indeed, i2c_put_adapter() decrements the module refcount while of_find_i2c_adapter_by_node() does not increment it. This leads to an overflow over zero of the parent adapter user counter. Use the dedicated function, of_get_i2c_adapter_by_node(), to handle correctly the module refcount. Signed-off-by: Herve Codina Acked-by: Peter Rosin --- drivers/i2c/muxes/i2c-mux-gpmux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/muxes/i2c-mux-gpmux.c b/drivers/i2c/muxes/i2c-mux-gpmux.c index baccf4bfaf02..8305661e1253 100644 --- a/drivers/i2c/muxes/i2c-mux-gpmux.c +++ b/drivers/i2c/muxes/i2c-mux-gpmux.c @@ -52,7 +52,7 @@ static struct i2c_adapter *mux_parent_adapter(struct device *dev) dev_err(dev, "Cannot parse i2c-parent\n"); return ERR_PTR(-ENODEV); } - parent = of_find_i2c_adapter_by_node(parent_np); + parent = of_get_i2c_adapter_by_node(parent_np); of_node_put(parent_np); if (!parent) return ERR_PTR(-EPROBE_DEFER);