Message ID | 20231020153017.759926-4-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 fe16csp1138330vqb; Fri, 20 Oct 2023 08:31:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQjadLGw1ujUm7l2ExjOMrkf9aG5FUdetf6kbka3+w1MW5F4bT5In+Gwib2zozh39i+dvR X-Received: by 2002:a05:6358:7404:b0:14c:704b:d19f with SMTP id s4-20020a056358740400b0014c704bd19fmr2301759rwg.3.1697815892481; Fri, 20 Oct 2023 08:31:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697815892; cv=none; d=google.com; s=arc-20160816; b=lbGPyCDQNvpBBIIqs4QUt9el5PtJakedZymD7KfapV+rudrWedyaxAlS3uSwCrf2Jv bXNiW5seK0qK7fKmSGDcFeD3DLQ9FayiCpcTIym4HEItha2WL9H5+A5c2icheqCqzo4h WCVVZHftUhFqYhUvdqs9wSWKwqQCKLUmAwcPEB+oyvrD4E3EFWtPlUgu1VCMuOz1zIpm Bc/h+14JkR/wy1OvFUKNtjbC45FX0Rps6OVHyDMJn5fbDt6KyID354YGP52P+zdhOI2/ rs2/gQ6w+DMv5Z/PFuRuE+XERrhnZcGjbgXHQbaIDE6zmfZMm3FpMwcWjj1MM+BpFmj4 2aag== 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=LpkSQeveUeewBTxaJFyVrBiY7AoHvN0hE8hZ52cDayY=; fh=Sta4bkXeXRIukawSYk6t6DEZpd4ZVxmnfg0oFV/KzfA=; b=CAs3PkjwYKaAYcnR3BdcTudG2FClbTOnRjT/72Bp2xX/YIgp2qSVTKgcM1sVyI5ZTF w4GkblY6tWabmup25I5k94tYiAL+WzaONWh/IVlsEkkUJ4SRsP6sYV4AX0vOc8pVaiuR dmTWKSTJlZSrXeI8dQqU1t5vKm1aSGuiQ4LYayfTNqOcNwDtJbAYsOVNPjn+PEuoaMMD pqdVqZZF0q5agRlJDYRAfnkWrjBrIPn5tUZSO8NGN5/8V83Lqp2WTojWer0WpCM3cf1N sfGPniUU6AQhd8qHf+UultFJrUM8ZRcdIHTlIvsKX+jbq5aCrAqLFBRt0gPRSnOuT0SU dOaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=OuMTtuTs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id bu15-20020a63294f000000b0059cd78384fdsi2115129pgb.222.2023.10.20.08.31.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 08:31:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=OuMTtuTs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 246F283AC5F0; Fri, 20 Oct 2023 08:31:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377750AbjJTPap (ORCPT <rfc822;a1648639935@gmail.com> + 26 others); Fri, 20 Oct 2023 11:30:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377726AbjJTPa3 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 20 Oct 2023 11:30: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 68BDC1A8; Fri, 20 Oct 2023 08:30:27 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPA id DF5DAC000D; Fri, 20 Oct 2023 15:30:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697815826; 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=LpkSQeveUeewBTxaJFyVrBiY7AoHvN0hE8hZ52cDayY=; b=OuMTtuTsfHK6E+16NET+zVwtnX4o+Xw9/X7wdTuWuRBpjJ5jdIChiURZAUu5RmWLvsB2T3 9T9vA38ADHg9rQhKOv0J2IKStBUWX73xMAJIKH6ebMUfsLlEeyo/V/cPqMJbHHCDLRdFT3 whXqROauSPkco0ha6pH7rqag50cww3Nehn5ycYMB1k3jMYZVaOQyRNdfFeCxJ1mCHV3IaD tQ8gvIxiTf2fiX7znhONmol9gf1Ig7oDlavgMgKgttyQAZcvsUJuuJNufpWay2pmDszPKH QgwDu2WUlMViWKQK0xdy2jbR1VlcbfaEFJHJqfp230QjADYt4b8TkrhP7Nm7Ew== 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 3/3] i2c: muxes: i2c-mux-gpmux: Use of_get_i2c_adapter_by_node() Date: Fri, 20 Oct 2023 17:30:13 +0200 Message-ID: <20231020153017.759926-4-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 morse.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 (morse.vger.email [0.0.0.0]); Fri, 20 Oct 2023 08:31:27 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780288996813424081 X-GMAIL-MSGID: 1780288996813424081 |
Series |
Fix i2c mux module refcount issues
|
|
Commit Message
Herve Codina
Oct. 20, 2023, 3:30 p.m. UTC
i2c-mux-gpmux 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: ac8498f0ce53 ("i2c: i2c-mux-gpmux: new 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-mux-gpmux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Fri, Oct 20, 2023 at 05:30:13PM +0200, Herve Codina wrote: > i2c-mux-gpmux 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: ac8498f0ce53 ("i2c: i2c-mux-gpmux: new 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-mux-gpmux.c b/drivers/i2c/muxes/i2c-mux-gpmux.c index baccf4bfaf02..8305661e1253 100644 --- a/drivers/i2c/muxes/i2c-mux-gpmux.c +++ b/drivers/i2c/muxes/i2c-mux-gpmux.c @@ -52,7 +52,7 @@ static struct i2c_adapter *mux_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);