From patchwork Fri Oct 20 15:30:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 156186 Return-Path: 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 + 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 ); 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 To: Wolfram Sang , Peter Rosin , Stephen Warren , Rob Herring , Greg Kroah-Hartman , Jonathan Cameron Cc: Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Allan Nielsen , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni , Herve Codina , stable@vger.kernel.org, Jonathan Cameron 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 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: 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 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 Cc: stable@vger.kernel.org Acked-by: Peter Rosin Reviewed-by: Jonathan Cameron --- drivers/i2c/muxes/i2c-mux-pinctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); From patchwork Fri Oct 20 15:30:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 156190 Return-Path: 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 + 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 ); 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 To: Wolfram Sang , Peter Rosin , Stephen Warren , Rob Herring , Greg Kroah-Hartman , Jonathan Cameron Cc: Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Allan Nielsen , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni , Herve Codina , stable@vger.kernel.org, Jonathan Cameron 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 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: 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 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 Cc: stable@vger.kernel.org Acked-by: Peter Rosin Reviewed-by: Jonathan Cameron --- 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; From patchwork Fri Oct 20 15:30:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 156188 Return-Path: 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 + 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 ); 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 To: Wolfram Sang , Peter Rosin , Stephen Warren , Rob Herring , Greg Kroah-Hartman , Jonathan Cameron Cc: Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Allan Nielsen , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni , Herve Codina , stable@vger.kernel.org, Jonathan Cameron 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 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: 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 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 Cc: stable@vger.kernel.org Acked-by: Peter Rosin Reviewed-by: Jonathan Cameron --- drivers/i2c/muxes/i2c-mux-gpmux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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);