Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp848443rdb; Fri, 20 Oct 2023 00:37:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFJSaIIoTWwzFBjEmEHttC6zAT7IBiT/iAPYRLouwK8Q6h+d8Sh844a+YhtQES+hdopmcds X-Received: by 2002:a05:6a20:3955:b0:151:577:32d1 with SMTP id r21-20020a056a20395500b00151057732d1mr1365294pzg.22.1697787476844; Fri, 20 Oct 2023 00:37:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697787476; cv=none; d=google.com; s=arc-20160816; b=zkdyY9bh2qR9r+ZvoW61TMZaMOaXFKvoMsc7kJ0hz5i5Ad8VStZMVCrGSiuXhXPYhS UKpldk09dyAi5Ao4Q6m5iNjuXYTXurmLdCOdyFWDgIQKbcPeQEuuoAZRlq4yE3RxFlhd ZqYBHDNgxyubPyNwaVm4a1Isc4RKpowbbxO64KOpCjDEIxvEvl+TXMLvlJFTL1f3UZAd spsbCtdXCDx5Rzlw0qBadZt3pPFrPiRAjagQUoxZWfpE4gYa04aZoHJzTlKh2APDay19 ySpvgva/66LXog3c1YqFzhDWB00rmQJfiOpAp+a/Fxou1/z9vJ1n75AOZ7ZayAJVJ5ui 3WSQ== 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=ra0oi89w1EGz0L4D7GGTtXtY3K5AWmaUKzsn3iFZYX0=; fh=es9SiJmLZst2H/WviS9aEpkSdacORbgliPvuu/J7+RE=; b=I9AmKNIhVXjFfhc94wCRYIGcQCH0i8Wt4O1COkDbV3NbElhm87O6BpszA3F/4P6+My vL73Zh2SjToG+B4u0n410Vr2wbkjUymixdMnonGzkqDZPyC8+EfyyuPxIBUZufnVFDNY nIIvCY9xGtJn4zK2g4GBBbq5BJpdveNJgKYBGfQ459oq1xZJDMSxf9SXGLr6W7bBDnPH hRP+8I+RuFpRCt6vgVWQkeXQByHo5C4el730H7XISiGchFZpmfQWTvFwCMUYSdZZNldf Tg+qwImKOzwoZAB28+Nz60Cph6QaU3cSoD5ruxNZvTXq8gCIQ7RSiQkgtrceLDYUTIKq kK2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Vd7RPiiD; 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 d1-20020a170903230100b001c9c496bdebsi1362376plh.337.2023.10.20.00.37.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 00:37:56 -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=Vd7RPiiD; 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 B2550826C608; Fri, 20 Oct 2023 00:37:54 -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 S1376426AbjJTHhq (ORCPT + 99 others); Fri, 20 Oct 2023 03:37:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376317AbjJTHhp (ORCPT ); Fri, 20 Oct 2023 03:37:45 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D03593; Fri, 20 Oct 2023 00:37:44 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0980BC433C7; Fri, 20 Oct 2023 07:37:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697787464; bh=GI0hZ0zC3w4UUqmfCOExvfTwcUMptnt24qo2d5p1zbE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Vd7RPiiDjoRn2Pf5P5hsRPkxBRtoOCxPVHBrqddJRbvy31jolrs/XDfbrce9fZzJo uk7X9vbTNc85QlTeMdscZWrPwfEXxKvpKfsvXR9dKuRv8+ywId3MnH5C4kTGnayD+0 RDGngcjYm398wLzCBsVfrTX93usg9qtKDUpZBdav1Nqt/irXGymExdD+Z/gTMva75E wRWn3Augi+8zw77eaMNV5x99e8IQHoCU7zaxV99Jx4kyCCCJfwvEULjKOkphPFV3fM ti7izaewwiOSX2Z9vG3oYxkTwndj0znxoHSDrolObqpRejY6ay9ZscrVlkDyWUGbbp 4WC2HH73tJz4Q== Date: Fri, 20 Oct 2023 08:37:34 +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 3/3] i2c: muxes: i2c-mux-gpmux: Use of_get_i2c_adapter_by_node() Message-ID: <20231020083734.20fed5c5@jic23-huawei> In-Reply-To: <20231019101017.425284-4-herve.codina@bootlin.com> References: <20231019101017.425284-1-herve.codina@bootlin.com> <20231019101017.425284-4-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:37:54 -0700 (PDT) On Thu, 19 Oct 2023 12:10:16 +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 > 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);