Message ID | 20231019101017.425284-3-herve.codina@bootlin.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp276759vqb; Thu, 19 Oct 2023 03:11:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFY3uORcAz0rpdZZzNVpkz2bDlp1mCy6ujGtlJy1Hwxinr+RrH2xpLKNBvB7JkUtqwBBaF7 X-Received: by 2002:a05:6a20:3d90:b0:17b:129b:1817 with SMTP id s16-20020a056a203d9000b0017b129b1817mr1761695pzi.45.1697710261542; Thu, 19 Oct 2023 03:11:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697710261; cv=none; d=google.com; s=arc-20160816; b=Ajc87uyItkDg3mhs/fU5zMr2HNqeXGwAQaVh+ceQ2CV1I2IDUhJgY6MygFMWm3otEu sHiPWN5AKXnT+Bw2n90P0QFqaZRiRL7OG0Rir9R1toE1LrLI5acihxWe1B04Cwi2p8I5 rWA37VTp+PnR7gM7MsbUzZlWME/oMWgJiquEy3d++Jg0uHWYj6leJQSz4sn3HFgydBHs +v83NV4PK+4t4rmRPkyWfgcgXaqWiNA+LVLMa5IXJX1opZSdHAmZSI6pR1Hv8vA0DVH+ Qq06UYphHYuY11RC+Jsm4HTw2GzAbhU72Xf0JeO6WrJiHJudImtuLr/L0n9cJmR7OGE/ 2n/g== 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=W7jPRQFKI6wZgsciHnAMnsGgniJttHvKS7IyImeZkgA=; fh=i3WS+6AgTKP10/eUP7j46CA4B/XR5qlEIT9hV1ltHe4=; b=qkkKdjYXp2mcwG8bnFfcFpFz5IjkQHFfL4/U4nhX/q0+vabj4OnuIzVOkHQf3pJmaH V0CQ2s4PMOwlRfffSSVlv7Q+uyceZVHNsBS9r9CtIv0Kr/8AG+Mi0LZdz4H9BNrjD0qI C5I+jA/ZbSdRMa+g+1Ik+JnAxjNPAOvSu9y9TCD0NwUDJn+odnanqmCbfZt98EUdpnI1 xpuW9hRTaoBzlS7QkHqI9zr0aT/4reXT0d2kNaOL3NCJ514m5drlRDX/ls7y1PZ6hHRm xc808znVGKsFWcnzRyn2NhRBgEzadvVrkVRyKzaux9ktxmt4+dJH3VBF6CWy3tdkwxwN 5WKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=PNSe1bRt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id g11-20020a170902740b00b001c60a0a8d2asi1710063pll.282.2023.10.19.03.11.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 03:11:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=PNSe1bRt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 3E53081A3286; Thu, 19 Oct 2023 03:10:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345250AbjJSKKd (ORCPT <rfc822;zwp10758@gmail.com> + 24 others); Thu, 19 Oct 2023 06:10:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345237AbjJSKK3 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 19 Oct 2023 06:10:29 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E6EE11F; Thu, 19 Oct 2023 03:10:26 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPA id 862ADC0010; Thu, 19 Oct 2023 10:10:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697710225; 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=W7jPRQFKI6wZgsciHnAMnsGgniJttHvKS7IyImeZkgA=; b=PNSe1bRtywJ7gCCE1egZvrQC80IKxPe6enwYn8KLh9BNuZceqnxTvz6ghYJf5GWGXFRgz5 O3b2RaS72HH4iUr0gUtn9gy1hCCqcRDnf/WORf6WREciPdFPWcqdmw6oIYJCIwljYdlzcZ AAEljCWFxLr62AJp8O8xjbdWb71vFQkEkc5Uk8w6i2esSaWV0OSiNc9PgP/aZYUOtzhHdU UJfGHmpjWnsLejK5mJYprbSSXx5Q7Mdn8qFNThFvdeUatYz0zyZMPiHarxN3WTiXfoWbwj tsjsLd0ucoU4r/jH6uLDIJDzkkaqG95ephnsCpb7M1g1FWMWJaIzQEPtnujhTg== From: Herve Codina <herve.codina@bootlin.com> To: Wolfram Sang <wsa+renesas@sang-engineering.com>, Peter Rosin <peda@axentia.se>, Stephen Warren <swarren@nvidia.com>, Rob Herring <robh@kernel.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jonathan Cameron <jic23@kernel.org> Cc: Wolfram Sang <wsa@kernel.org>, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Allan Nielsen <allan.nielsen@microchip.com>, Horatiu Vultur <horatiu.vultur@microchip.com>, Steen Hegelund <steen.hegelund@microchip.com>, Thomas Petazzoni <thomas.petazzoni@bootlin.com>, Herve Codina <herve.codina@bootlin.com> Subject: [PATCH v2 2/3] i2c: muxes: i2c-demux-pinctrl: Use of_get_i2c_adapter_by_node() Date: Thu, 19 Oct 2023 12:10:15 +0200 Message-ID: <20231019101017.425284-3-herve.codina@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231019101017.425284-1-herve.codina@bootlin.com> References: <20231019101017.425284-1-herve.codina@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 pete.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 19 Oct 2023 03:10:54 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780178235098561165 X-GMAIL-MSGID: 1780178235098561165 |
Series |
Fix i2c mux module refcount issues
|
|
Commit Message
Herve Codina
Oct. 19, 2023, 10:10 a.m. UTC
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 underflow of the parent module refcount. Use the dedicated function, of_get_i2c_adapter_by_node(), to handle correctly the module refcount. Fixes: 50a5ba876908 ("i2c: mux: demux-pinctrl: add driver") Signed-off-by: Herve Codina <herve.codina@bootlin.com> Acked-by: Peter Rosin <peda@axentia.se> --- drivers/i2c/muxes/i2c-demux-pinctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Thu, Oct 19, 2023 at 12:10:15PM +0200, Herve Codina wrote: > 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 > underflow of the parent module refcount. > > Use the dedicated function, of_get_i2c_adapter_by_node(), to handle > correctly the module refcount. > > Fixes: 50a5ba876908 ("i2c: mux: demux-pinctrl: add driver") > Signed-off-by: Herve Codina <herve.codina@bootlin.com> > Acked-by: Peter Rosin <peda@axentia.se> > --- > drivers/i2c/muxes/i2c-demux-pinctrl.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Hi, This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree. You are receiving this message because of the following common error(s) as indicated below: - You have marked a patch with a "Fixes:" tag for a commit that is in an older released kernel, yet you do not have a cc: stable line in the signed-off-by area at all, which means that the patch will not be applied to any older kernel releases. To properly fix this, please follow the documented rules in the Documentation/process/stable-kernel-rules.rst file for how to resolve this. If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers. thanks, greg k-h's patch email bot
On Thu, 19 Oct 2023 12:10:15 +0200 Herve Codina <herve.codina@bootlin.com> wrote: > 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 Odd spacing in here - looks like some tabs sneaked in. > of_find_i2c_adapter_by_node() does not increment it. This leads to an > underflow of the parent module refcount. > > Use the dedicated function, of_get_i2c_adapter_by_node(), to handle > correctly the module refcount. > > Fixes: 50a5ba876908 ("i2c: mux: demux-pinctrl: add driver") > Signed-off-by: Herve Codina <herve.codina@bootlin.com> > Acked-by: Peter Rosin <peda@axentia.se> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> > --- > 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;
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;