Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp240222rdb; Thu, 19 Oct 2023 03:11:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE8Ixd1M08ZRnI3OZxV7I/PL2El8LNRLedOF1bFxD0I8Do+a80RlHkQNpQrj4rQirIgYxSh X-Received: by 2002:a17:902:778d:b0:1c9:d0a0:ee88 with SMTP id o13-20020a170902778d00b001c9d0a0ee88mr1793249pll.62.1697710267024; Thu, 19 Oct 2023 03:11:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697710267; cv=none; d=google.com; s=arc-20160816; b=ZY8w4X+RhxMB+YcCiKJRbCRODHz2nGnCH49VI4NfTJyoEswZQBeBZwv8pZT1rNaJm3 2GqerJDtMHVRGkTNGo6To3f93pQyRppxslpNy/He18goej1bvIWwDG8js6qOkCht1vz5 msM1Q/BANcRAgJASa7ApikCmhkl0glRWqf6BslfQp3/Xs4otE1cEKeSNm4MH++kz2avN HvkCidudlfafA17PPacvmfQHJo/qc8pO/NTdYmFTmIn5gQeLHoJQqlELrRxqnC9dn1UW n0sfGjxDxDfT8GBpAF2YhyWnVJBe8PZtSiPM/OfyKEd7e2jfjjwL3iOOVZMw9mwjv5nJ puYw== 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=f2DfQVfMOTqX54BnA6Gk9Zbew9GqeeC0hjdrSJyySQk=; fh=i3WS+6AgTKP10/eUP7j46CA4B/XR5qlEIT9hV1ltHe4=; b=MrLJOjdjSW4Dhm1KFPAmnjyUU8KRBMnHE6LB6XXJ+h7nvgoon2bIbtMM9YIWaT4OgU axHhDIcGa4tfCYognIAAFruT5Ggi/vj9YvNtnFTOLyN5vrLbwWZodH4lgfGwWoCmIt52 LPFTXls7bFSX+heDV4kiLplBDpx1wtd4FoJ9dmKqoHKAz0fMs2CdWwHqaEjYNJalEuAy Kw5nlmQt6F+/zvyWddXLs0xwT1Vc/vcH+oZdRuMgWZ4GRF+HBTZsNE1JItfweuy9YSQp hdFSIiJqh7UWtWltlg8vMZ1oaU+/FL2XGDR3abVFOvVnZqCv0JeyjlcBJa+BO59iRoEv WEVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=L1gjMYua; 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 Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id e3-20020a17090301c300b001c6154cfda9si1978447plh.356.2023.10.19.03.11.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 03:11:07 -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=L1gjMYua; 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 B9F8E80907B0; Thu, 19 Oct 2023 03:11:04 -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 S1345264AbjJSKKg (ORCPT + 99 others); Thu, 19 Oct 2023 06:10:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345206AbjJSKK3 (ORCPT ); Thu, 19 Oct 2023 06:10:29 -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 E39BF11D; Thu, 19 Oct 2023 03:10:27 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPA id 28575C0012; Thu, 19 Oct 2023 10:10:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697710226; 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=f2DfQVfMOTqX54BnA6Gk9Zbew9GqeeC0hjdrSJyySQk=; b=L1gjMYuaxDZELtkF3+eTQVZ2YaMlzad1cYuHCVsW3VpKNTEusFo2LUj3IADZkPPmJdLFIz 2ObVkQYrkTW4Eciqf5qzd1/sek+1I4YvPc4+OmOG/vIOM5yUIloPFfMCE6yq4GdS6kmvYA +ZOyGg+blKXU0dIMl+69tJvlrNjxgAAdebxYDcNXJopDsiTCWtYATh3MIPvGofFUWYdlAP PmCDbnYA7k4VYX/QPJ7AwHTGT6w3feTHExQ+ORt7Or7KOBKsWa5/mrvlPeijS+o1tXVU6J V8ZTHzO9b5/CDRKvoo6xdenYu1hJob+uvn5uVFdwoB606zRePxe9xaJ9GpOh2g== 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 Subject: [PATCH v2 3/3] i2c: muxes: i2c-mux-gpmux: Use of_get_i2c_adapter_by_node() Date: Thu, 19 Oct 2023 12:10:16 +0200 Message-ID: <20231019101017.425284-4-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 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]); Thu, 19 Oct 2023 03:11:04 -0700 (PDT) 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 Acked-by: Peter Rosin --- 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); -- 2.41.0