Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp847391rdb; Fri, 20 Oct 2023 00:35:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEw3CCa7Rh/9NlV9FrpIJ/62oiG0EyHOBvV25tgTXd4EXQpQANuww/VqMQ/D03AaC1UExPn X-Received: by 2002:a05:6a20:748b:b0:161:536d:a13b with SMTP id p11-20020a056a20748b00b00161536da13bmr1073861pzd.18.1697787314787; Fri, 20 Oct 2023 00:35:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697787314; cv=none; d=google.com; s=arc-20160816; b=HfAdMpDmSuSirYKXb/jRFFxFq0x7OI/AyD+tm8BU72QUk5ro56PfKRYU0kj9CT1z7a Wc8offOkawsGBY63OB51Wr8Kmk1cmKDs6fsuLJ01v1x3fL2smss+kVqV+pdgqOzI7CmA QQ5bUqk8V1TeAZgYSNhwbrwb9mwxHqEcrR0nTWjsoCZDaCDQiI5Z6KUwAqh30jsvaBiP mdXiHLeGneEdeyAUxAZAT09FOMm2UOc3MfaVnCcKOuat57TvPeCS+h5LTdcJCBFkHyFK gElyf+LQgW28MRQ3CvDrx6zLnP5tUBppUumAFerSmewI2ceG/eXWAxPXJgJPU+MK8f5a XWPA== 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=yqzLmeX5EwC0PY3Nh0FlHVZv7Y978kXj7UtxmFYrMfw=; fh=es9SiJmLZst2H/WviS9aEpkSdacORbgliPvuu/J7+RE=; b=n++mPGSG7KZ43s9/osubS0QHFkfW7tdzDnw04m9N+gH30puKVXM8+6RuWzg/e+dp8n hpbZ9VWek8lSVh8KmWCLvnwSy3c43Bt/ODkcHtq6zcX4wxighxlt4Tzn6RDq9ISIPKy/ 6Bu3NPa+vqRIT8aZ2okDh7CdxDJsxV5KZIaZ3cabC5PSK0TFNhj/S+Wahh+UlsGAyDx2 HJklmbRbLvE4Y4LR6m7V0YjpB5xDFXLjbALO1/cZtnwiOgaaUeIGP5KZSnzEL5f0wPOn SL7tjSE/CRSvCDfX8QO6yzNVA4nzW8bzJy38N1D4FNrUjEaS97OL04g6d+YDYZTLTeXo YPcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aYIXA7yu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id l13-20020a170902f68d00b001bb20380bf9si1372992plg.545.2023.10.20.00.35.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 00:35:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aYIXA7yu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 9FD3C81BD021; Fri, 20 Oct 2023 00:35:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376403AbjJTHfC (ORCPT + 99 others); Fri, 20 Oct 2023 03:35:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376317AbjJTHfB (ORCPT ); Fri, 20 Oct 2023 03:35:01 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 125BD91; Fri, 20 Oct 2023 00:35:00 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7958EC433C7; Fri, 20 Oct 2023 07:34:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697787299; bh=LuJ0EX2tXxho4nJTr8yfLdNrGYlhYAkXm6+rPpQQTKI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=aYIXA7yuJplTFlsba10PHWyASznbHDLRFDB1Jbh0PbjcXOEe1sFLkMRCecB1EYRPw 65SCVp8asIlIr+gB/DNrCBi/csSwpm5QSWAKuGlYl35CNWAkMySMBHc7Tqd/Xnk7Kh 8nKuUmiidgseqR5T2PKMLRIFJaJGQNNAT27u6XnXazxKPplRGpGc000k9nfFf8MALF FG1TOtK9vc2s70blsMD1P1OUg8/ZdUV36EZuLxZhNwxkYV0RVqkOdUSHbr+TziOSPH snu0m8rJhKyD25djVPC2Fd+9TOaWIk0HxJJrfutiU1j5MMhf4u6C7ySG/0law8D/UD uKs0mfs2ie/4w== Date: Fri, 20 Oct 2023 08:34:49 +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 1/3] i2c: muxes: i2c-mux-pinctrl: Use of_get_i2c_adapter_by_node() Message-ID: <20231020083449.3393191f@jic23-huawei> In-Reply-To: <20231019101017.425284-2-herve.codina@bootlin.com> References: <20231019101017.425284-1-herve.codina@bootlin.com> <20231019101017.425284-2-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 fry.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 (fry.vger.email [0.0.0.0]); Fri, 20 Oct 2023 00:35:12 -0700 (PDT) On Thu, 19 Oct 2023 12:10:14 +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 > 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);