Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp847855rdb; Fri, 20 Oct 2023 00:36:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFnHwM7yzvs9jxmg/MPOuHKfnuTHpts1U+EY1J8uDnLApuW1bCuiOuWjNQsBw65bZ4tPHJB X-Received: by 2002:a05:6358:418d:b0:166:e153:db13 with SMTP id w13-20020a056358418d00b00166e153db13mr875826rwc.16.1697787388221; Fri, 20 Oct 2023 00:36:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697787388; cv=none; d=google.com; s=arc-20160816; b=pSL8J7iPZv1utmPddLtGV1H3SAeZ3uoD9lbjvIIj7O4DIO+DUytHsTQewWugxLnubv RS+mvvWWJOo++GOZtUTOKsvHdccP+bnig1RKKOn/ItQ7PMloPFMsEZMDDchPuIQlK9hS 6+ICExYln0BMiJLjrP7ZniV/VDm5jdDFwNMx1euV/LUwyC6JM+INPNbnXysX1pD/oLMc nJ5SJwVqa7bYCdJIKhYg86xyXKo/WQDCpZEboDYWUYgWniB+LW+9fdOKfWgQ0ldCZkXw SFqLR2S3BNE1cr7In05+Z4IUd6kIvDxXpYlqFjj5oElggX/J29RG4kT5ovYhqUkn5RaS 44SA== 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:subject:cc:to:from:date :dkim-signature; bh=mNtFUGV60YeduigY1jGbMmzpuJFP34Sd0Ipirt/lefY=; fh=es9SiJmLZst2H/WviS9aEpkSdacORbgliPvuu/J7+RE=; b=uQ5jgPk96sIqRQRo+Pe4rZGpX75yMpKkY4Ff2aoUFNdutLTrwEGpjCf9VpAdmvTFYy itLKWpEwnbVTQ2Mc/SjtTnPq8yj+kjWIEpptDRN3aqbS6RWKgPRCU61fJ9hbwpGNCukx iCTJUAwTTwK8oLpyIcjaHCOP1QAuAAEasC9qyB/x8GlzfPPbh+ZkePypgsKSuTtVf18B b8HlHEPaGk9f9ccrfc9VTRShlVBGHEglwuVPWGCW1K/mbZ6s+gw3yT3ggLBE806dN/ki QiPNTndKhAvzB9psdLS33evppYxkqig4RJgnAX0AXaQv5ro5vQa+EXBVjyWPgDqisAa1 BDOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="S/kBVDry"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id s24-20020aa78bd8000000b006b5273b8d14si1322576pfd.72.2023.10.20.00.36.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 00:36:28 -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=@kernel.org header.s=k20201202 header.b="S/kBVDry"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id E4391826C601; Fri, 20 Oct 2023 00:36:25 -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 S1376406AbjJTHgT (ORCPT + 99 others); Fri, 20 Oct 2023 03:36:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376317AbjJTHgS (ORCPT ); Fri, 20 Oct 2023 03:36:18 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9614F91; Fri, 20 Oct 2023 00:36:16 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AA54C433C7; Fri, 20 Oct 2023 07:36:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697787376; bh=AymAZO6gbIxJ9L3YYTUNFLQW1Cg2kqmrNd2l5JYo0to=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=S/kBVDryf8JHx3Z3OUXqZk4g//GJcCeSq9f3bmle451XltZ7TeCoU0ezXsvALksLh 7o1sm0eDDhFv3LEN/46ypYtTH5QrLqkqHKZIbzYAEzMWZtWBnbeQg/ek1OrT3qa6o2 c+jA6rn9/Ev09QyAXWRJD8MRUtChRBO8j67h6G9utgPmX6cmAt3Rq/YlAGti76FiFL SNKpqJBynfboqC7imSBnh7UWdd4xNdr+fL8yF25LskO3mwFAAXwfE7pbT0CQeJ+/Us zIZ6pb9SxQueTn3rO4Q4gFk65ihb4JQc6NP4pERvzJZLi0okupDZRJvZH1ibQnE7DE QTtu4nUZUCShw== Date: Fri, 20 Oct 2023 08:36:05 +0100 From: Jonathan Cameron To: Herve Codina Cc: Wolfram Sang , Peter Rosin , Stephen Warren , Rob Herring , Greg Kroah-Hartman , Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Allan Nielsen , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni Subject: Re: [PATCH v2 2/3] i2c: muxes: i2c-demux-pinctrl: Use of_get_i2c_adapter_by_node() Message-ID: <20231020083605.278df5f5@jic23-huawei> In-Reply-To: <20231019101017.425284-3-herve.codina@bootlin.com> References: <20231019101017.425284-1-herve.codina@bootlin.com> <20231019101017.425284-3-herve.codina@bootlin.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 00:36:26 -0700 (PDT) On Thu, 19 Oct 2023 12:10:15 +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 Odd spacing in here - looks like some tabs sneaked in. > 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 > 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;