Message ID | 20231020153017.759926-2-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 fe16csp1137963vqb; Fri, 20 Oct 2023 08:31:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcL9kVtx6JKha7qDl0bXIzZfxrlezuxCpG02LsrCf4FuWmFm2sYfYj5uZFB2Sj/F06PQop X-Received: by 2002:a05:6a20:840b:b0:163:5bfd:ae5b with SMTP id c11-20020a056a20840b00b001635bfdae5bmr2581311pzd.15.1697815861076; Fri, 20 Oct 2023 08:31:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697815861; cv=none; d=google.com; s=arc-20160816; b=BsGkFr9dfqcU3fs4gL4UZsPHu5n/ok7HI5YaYShkEMybu9ycrKNEXfM4vZtTICVVs8 vTUJTOOvTB57g+NSpqcGReKSFYWJdEUlF5fh9hFSVQAXURuFeRCf5e8yV1B9iXP5uaw/ N1Wy7InQsigNg0W03VvMdFdmJbbZn3t/KQuEU+p9njdig9hckhEkTcFG69Ja4kdRSedg nsrQ7gdCbf02TEALw2Yiatfz6/4V8Mqa4zsUH5Cw/hgbiH3IeGBMZbfkvFCcfeJpu5Ge kzTvRBUoZpNyMUuKOAovLFJdVdDyLFVCkumiRpU7wHgQXhk8S5HEvm+7c2ACK88WGpJR +9nQ== 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=AM62ZlFQTzCoejFnnmrothFoj82sgbfnGqDeWLVxoAQ=; fh=Sta4bkXeXRIukawSYk6t6DEZpd4ZVxmnfg0oFV/KzfA=; b=cu4JSr9et2wjZzL3pO3oDc+WCrx/4FoViro94ZEFD0mwyd2jH46sPOP0y0tv9eOo4B t0T4b/7+AMo5zPRhZY81gN2wnMEiuvbtYNIY6xxTPZ/FQD6fdzotOIUQZao7vHPAUa82 7Th14sso7Rri+SiBzzR6w9168BSoBR7Hyb4il1xRjT+A5tnRzT9wEELCB64x963g/oAO AHyxcS2GBnfttvNEMS80APFd+Ijig9dKgUk6Fqwkd04JvH20PXbRRyOPFMCwBjXGNwX1 cgobwtYBxw8RsKPe+D44tE6wFsi7O9kV+GKG7JxaUSZiKura2pt+wLgk9FBSvHahNmZK pdRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Xzd6NvEU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id b26-20020a63931a000000b005b8878c9b01si657886pge.309.2023.10.20.08.31.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 08:31:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Xzd6NvEU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id BBD4081E5E4A; Fri, 20 Oct 2023 08:30:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377734AbjJTPae (ORCPT <rfc822;a1648639935@gmail.com> + 26 others); Fri, 20 Oct 2023 11:30:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377703AbjJTPa1 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 20 Oct 2023 11:30:27 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD04AD41; Fri, 20 Oct 2023 08:30:24 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPA id 13D32C0015; Fri, 20 Oct 2023 15:30:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697815823; 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=AM62ZlFQTzCoejFnnmrothFoj82sgbfnGqDeWLVxoAQ=; b=Xzd6NvEU6m3B9XH238lvcZlu8oA05x/xQM4wq17E0ZSl2TtwSBTsBDhNEyuoCsYWhcohcf oKxPZgijH1BA//6g0glVVqtBdodUpuKDIyKD8etscS8vAlveDeB5xCrniUHqQkJ36TqIPJ 8X9B/MMGBwi/aeGo/6iqz/E1AhBw9aVZyLWlPz4/XIpBMXFFpc6CvwVr9OJz+83/ODy8v+ 0EwKlhvfsgSPKOzhUvvyn6GfoUJ1Rd5R9qGjQIpA5TKpJqjjkTOYpu4OxQXVx/2GT1Bwif 6nZqxkcqJoK/u+W1s8t7W27zCRlcoboMkCkU1u96honkOQ4nw+aCS0MydQ/esg== 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 1/3] i2c: muxes: i2c-mux-pinctrl: Use of_get_i2c_adapter_by_node() Date: Fri, 20 Oct 2023 17:30:11 +0200 Message-ID: <20231020153017.759926-2-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 agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 20 Oct 2023 08:30:58 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780288964013453204 X-GMAIL-MSGID: 1780288964013453204 |
Series |
Fix i2c mux module refcount issues
|
|
Commit Message
Herve Codina
Oct. 20, 2023, 3:30 p.m. UTC
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 underflow of the parent module refcount. Use the dedicated function, of_get_i2c_adapter_by_node(), to handle correctly the module refcount. Fixes: c4aee3e1b0de ("i2c: mux: pinctrl: remove platform_data") 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-mux-pinctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Fri, Oct 20, 2023 at 05:30:11PM +0200, Herve Codina wrote: > 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 > underflow of the parent module refcount. > > Use the dedicated function, of_get_i2c_adapter_by_node(), to handle > correctly the module refcount. > > Fixes: c4aee3e1b0de ("i2c: mux: pinctrl: remove platform_data") > 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-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);