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: 736470 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AC17CDB483 for ; Thu, 19 Oct 2023 07:35:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232948AbjJSHfq (ORCPT ); Thu, 19 Oct 2023 03:35:46 -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 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org 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 --- 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;