Message ID | 20231020153017.759926-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 fe16csp1138491vqb; Fri, 20 Oct 2023 08:31:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGyHsk6GhzRQTMHYXTgB4yBCGehxlGHvpw2rEXjvfC/cQPTiEQnJQZtuxoL5odW5liMD0rF X-Received: by 2002:a05:6358:261c:b0:134:ea45:53d7 with SMTP id l28-20020a056358261c00b00134ea4553d7mr2412369rwc.26.1697815904775; Fri, 20 Oct 2023 08:31:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697815904; cv=none; d=google.com; s=arc-20160816; b=GBVoCLNalM5QzKkSgENDm2S54sevgIQnuTMNA+U5+AZ+aXXY1fLwaPuqNeskqL10C4 LFU7qnHzaw2LsiE7BQmVKTVOQ9qgbZ+gQenQIVEw16LWmjGJIvL4x0XvHZ1KgR4yAJl1 DrF0eDRamf19K+d7/yHZAaf4ccI5RAvlVAgNkNyC1XpbEOyiqTPrrN+hi5nC6xNNfCh4 dPABGkNv/TZS95t/jhwaSNtKPUz/uT5OrBvtn3/+8n5U8xSa9Rgs9dwkHDCo0QN2Qfre bXT5jKI0W62R8JA2JtR77WQIXO4ES3et/J+DT8SHXeIkqf6YCgQYl+3OWhf+RLvVLdlN QQVw== 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=jnCAXBTR4Gk0ybvRoXY2t6uO7rWkWJb/Xi9lCq4E84A=; fh=Sta4bkXeXRIukawSYk6t6DEZpd4ZVxmnfg0oFV/KzfA=; b=ey0ZjoSfjdrbnGbKGvbUco3Cx5NoU+CahO9JzETsgDCCMoLV8wUbyDhlQ9nwU92hsk rFBM5EdqSQISBGX7inxCrcqSr4yymKlJwGwcWgbGB8IEq+e/Q18C1PgHIyNb9ay6eaun gyTg7c+UcmUY6qexTwGZ5KNcROvyarIk9enEaWF+aKxabbFZA1en1u2ET71/7mejeqKE 4QV5Il9GiK/lTL4wSdYNZ3Z3dL6ktIVATvIyBNycDoKedxjM3Yh0L5vTD7nc9mh/kUfP pYO4ACXsG3q9Ygjpju5Zw4Q8bzuoW2CiCqKlSopWP8DBLbKf1B7QpTQeo/9h5niyg2RV jAnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Z9Dsm6Dk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id i187-20020a639dc4000000b005b21d089aabsi2081549pgd.519.2023.10.20.08.31.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 08:31:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Z9Dsm6Dk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id D11ED8303B23; Fri, 20 Oct 2023 08:31:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377743AbjJTPaj (ORCPT <rfc822;a1648639935@gmail.com> + 26 others); Fri, 20 Oct 2023 11:30:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377712AbjJTPa2 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 20 Oct 2023 11:30:28 -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 E2B20AB; Fri, 20 Oct 2023 08:30:25 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPA id 497BFC0019; Fri, 20 Oct 2023 15:30:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697815824; 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=jnCAXBTR4Gk0ybvRoXY2t6uO7rWkWJb/Xi9lCq4E84A=; b=Z9Dsm6DkVdQiOljwZeY6Mw5nCw3sElISUuEqLmBJr3NaI7z4+3pEFezj+1Q4tKvXeQChNY K5Y0NjUdPtnNOqcuzymAo1tLI+aIu/TMcRsXpZ5K0KpnDkor3/LDlWuaWWLdCxvNLOBH2O O3/thMLHzLYb15VGAseErk8pYnfR+ZO81oYtSHI1NiLJEhq9SgqohRaOo2dI9jQ7e92rUj 3mXOvwBv6EzUh28pn98qMtsRSNc9bXkKR9CZCqFDwtwrPmn6Q7NuLl/vUYFbX5XzqEyh5s lqR/wul0StV0ZNoo2ut0G8HvEmBQrbJ81YDlyXnuuwwK2Zps1IZjSbpC5FmFag== 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>, stable@vger.kernel.org, Jonathan Cameron <Jonathan.Cameron@huawei.com> Subject: [PATCH v3 2/3] i2c: muxes: i2c-demux-pinctrl: Use of_get_i2c_adapter_by_node() Date: Fri, 20 Oct 2023 17:30:12 +0200 Message-ID: <20231020153017.759926-3-herve.codina@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231020153017.759926-1-herve.codina@bootlin.com> References: <20231020153017.759926-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 groat.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 (groat.vger.email [0.0.0.0]); Fri, 20 Oct 2023 08:31:05 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780289010146069106 X-GMAIL-MSGID: 1780289010146069106 |
Series |
Fix i2c mux module refcount issues
|
|
Commit Message
Herve Codina
Oct. 20, 2023, 3:30 p.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> Cc: stable@vger.kernel.org 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(-)
Comments
On Fri, Oct 20, 2023 at 05:30:12PM +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> > Cc: stable@vger.kernel.org > Acked-by: Peter Rosin <peda@axentia.se> > Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Applied to for-current, thanks!
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;