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;