🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #13326

Re: [PATCH] net: ti: icssg-prueth: Fix device_node refcount leak in prueth_probe()

#13326
From: Simon Horman
Date: Mon, 09 Nov 2026 16:52
59 lines
10083 bytes
On Fri, Oct 30, 2026 at 04:56:51PM +0800, laixiangwu wrote:
> prueth_probe() takes references on the eth0_node/eth1_node device nodes
> with of_node_get() and stores them in prueth->eth_node[]. If either of
> the "ti,mii-g-rt" or "ti,mii-rt" syscon regmap lookups fails, probe()
> returns -ENODEV without dropping those references, leaking the device
> nodes.
> 
> Jump to the existing put_cores label so the error path releases the
> eth0_node/eth1_node references like all the other failure paths in the
> function do.
> 
> Fixes: 128d5874c082 ("net: ti: icssg-prueth: Add ICSSG ethernet driver")
> Signed-off-by: laixiangwu <laixiangwu@cmss.chinamobile.com>
> ---
>  drivers/net/ethernet/ti/icssg/icssg_prueth.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
> index 591be5c80..9b971d1df 100644
> --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c
> +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
> @@ -2258,13 +2258,15 @@ static int prueth_probe(struct platform_device *pdev)
>  	prueth->miig_rt = syscon_regmap_lookup_by_phandle(np, "ti,mii-g-rt");
>  	if (IS_ERR(prueth->miig_rt)) {
>  		dev_err(dev, "couldn't get ti,mii-g-rt syscon regmap\n");
> -		return -ENODEV;
> +		ret = -ENODEV;
> +		goto put_cores;
>  	}
>  
>  	prueth->mii_rt = syscon_regmap_lookup_by_phandle(np, "ti,mii-rt");
>  	if (IS_ERR(prueth->mii_rt)) {
>  		dev_err(dev, "couldn't get ti,mii-rt syscon regmap\n");
> -		return -ENODEV;
> +		ret = -ENODEV;
> +		goto put_cores;
>  	}
>  
>  	prueth->pa_stats = syscon_regmap_lookup_by_phandle(np, "ti,pa-stats");

Hi Laixianwu,

Thanks, this patch looks correct to me.
And I appreciate your feedback to the AI bots.

But I wonder if this nearby check also leaks a reference,
because while it drops one, wouldn't there be two if the
condition is met?

        if (eth0_node == eth1_node) {
                dev_err(dev, "port0 and port1 can't have same reg\n");
                of_node_put(eth0_node);
                return -ENODEV;
        }

Also, for future reference, it would probably be better to put
two similar fixes for related drivers in a two-patch patch-set,
rather than posting them separately.
Technical Details
Message-ID: <20261109165235.GR18859@horms.kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359462-linux-kernel-netdev=dewy.ru
References: <20261030085651.1944-1-laixiangwu@cmss.chinamobile.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359462-linux-kernel-netdev=dewy.ru
From: horms@kernel.org (Simon Horman)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH] net: ti: icssg-prueth: Fix device_node refcount leak in
 prueth_probe()
Date: Mon, 9 Nov 2026 16:52:35 +0000
Organization: Usenet Network
Message-ID: <20261109165235.GR18859@horms.kernel.org>
References: <20261030085651.1944-1-laixiangwu@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="406634"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:1G4yDE/yuFI5h2ypLpe1GXvmMps= sha256:IOaZn3nQBf3nDoC2yyjdPsEzCa7zouTpIlDRbOyd3Y8=
	sha1:4CsU+1XZczqkUYjz7sWjN2bb400= sha256:AWVeSP/005K487Ejhq/SO2+6iYDWAE1fzuC+6Qf8buo=
Content-Disposition: inline
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id CE0FD1138A0; Mon,  9 Nov 2026 20:03:32 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id QGIcyXnkbpFk;
	Mon,  9 Nov 2026 20:03:29 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-359462-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 8739C11383F; Mon,  9 Nov 2026 20:03:19 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 94B86457A9; Mon,  9 Nov 2026 16:53:50 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794243166;
	b=tLutYf/8dq4kBW6V/LPWnay6HCQ1baFe2+djInfxnfb8ohgpYPkFc1N9ChAaZnzQYVcr
	 Ss/DDGtqn74ts8GrrKahjLXNALVEUt+Ky+Zwe10Cau2TAATLF18AH0sx0mgBRkWvWHNDA
	 4YQdw3zeUzvILZzaIw4IM+x52I8f9hPJuHAIfEgyDTI14sL/yZGpdPMeHvjpcywnTHvCz
	 vYuJ/sLtv5CedNwQBaKaQ822jfaxzX3vjyTgE9DzkqLFUpR/2FLvbU6jmUc/APuc1dybo
	 urhaGCj7roRoQyVA7RZKlM47yTzddokJwcgjs4Gc6doOaiAfI7DmURocOx7ksVevvqw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794243166;
	h=X-Original-To:Received:Received:DKIM-Signature:Date:From:To:Cc:
	 Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=WBEAXWn/Gapt4KuRgUjdXuXmF6aQgvDHYaPeKeySe5M=;
	b=lTUvOBuOUm2DKOxgbECHR1Vnyma4nHhrTbsNVTT//tSLyXHMI7cN4evG1UzBIulRFXzy
	 /ALiBdTbFL+Izol+aEk9Ja5Oz/50Fn+IFm+HD70eSHjha0DSB+Ct47gykKMe1O0fLJd/9
	 8BTZoXQg68m0GtivDern0ULDKHEM1ChFJWvgDSfh3OhuiY/W1qQCcM/dFiiM/bcAsIAQP
	 vDnSrDtmbzYV3VhLBZqjd5EudYs66f2mNCqHqcTbuc1PVHTwYV5T633Co/D+QjGecpRbU
	 9hAMKA+vpRkwjhnJN/kvOYtLY11EgAQgTQRTi4+o8JydhGnc69Sdy+4YgFoiyYBuqPA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=RiDATvMr;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 8526E60A5BFD;
	Mon,  9 Nov 2026 16:52:46 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=RiDATvMr
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794243160;
	b=hLDfEi6G4Vo1MdDt147CR+gvTedjm9Msrxlq9ohb/niQDSQm21Yyxp72cryKAyFQxi6F
	 khyYs+/Z9eBRFzUV6IYvIMf0lG0E9A1evqrKG5KIE3FQG091NkXA+LNsR76lOfisT+819
	 ZpfgXEKhZIuEe80rY5vBDdPwLwyQg+teF2oE7Ug9cdDJ4Q8tOJPsy8xMTx8zYCR6sx8ZM
	 S6SS6WS4bGbKcvgJRJAc42EBtYQjKm8+DPFsbDNmn0yWvmCrAPIPh9lPVajSagH4bHFar
	 DAasnE9KNJoYGqkuUNJkb5P5bMTTea27AADD6TEpx89bHwKK3Y9ZAyMLNsfYO9WrzTQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794243160;
	h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=WBEAXWn/Gapt4KuRgUjdXuXmF6aQgvDHYaPeKeySe5M=;
	b=AEm3c958KzKOveOvGi5ult5hdrEUJo2FCoF9aHcINa8MF5xgpwxm/15R5P7j8T+TbaWv
	 VSkWTjU+Fsc3o06gUidd7Qw/teWN1Duc3OIuBdCuNMS35DCocX1V3RJLETCZyvAuBqk8U
	 ym5eeOG+uqq6cs5xL6L2B7NvgZEyypoFNSPjiWTuCnZ7HHxsCVeCB+MCaBvo4oykYUU2I
	 YqcvmUBYT6PnwJUN292TRw+n7LgJOlqXIlMVRJVoU13xs6N0GuEFbUp0R0bUIwgSpegR7
	 cnwZshimm/rkL9InFQUdlohkEjb6F4DaK7JC5GqkFU7Q08z8oMPzXqYWpcCB6EHj4kg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=RiDATvMr;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B325606EEB2;
	Mon,  9 Nov 2026 16:52:39 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABF7A1F008A4;
	Mon,  9 Nov 2026 16:52:37 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794243159;
	bh=WBEAXWn/Gapt4KuRgUjdXuXmF6aQgvDHYaPeKeySe5M=;
	h=Date:From:To:Cc:Subject:References:In-Reply-To;
	b=RiDATvMr5i+6a+a/3TSoFjEem7mY9e+KGFYsasZ3YUc+Rw8yN0EuQeD1kXOWu9fXW
	 cExmFrfntUc2ac0z86BKSjvl7FmL+KvI4boWTfTT8zUjyai0stzJkOFJF5pTvCeqZf
	 rMvx4g3ZqxyuP0hAqN5gY80niOdZ10INxgte3pm9I3kDedKTsG1NLgbGZUsII0RjJj
	 koCeqz1+qPnmOvFjAfal+mId6Ct8lT6dhBmMaOdHpA9MgKdLHsDz1iRy0OMTkXZrtb
	 83/gp2GuHwViHaPHJlXOENgaxxUULz++FZwv35N13/g8Pl7rU74mVtgit2y38IlUsS
	 1LmUTEwg6z9Qw==
X-Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	MD Danish Anwar <danishanwar@ti.com>,
	Roger Quadros <rogerq@kernel.org>,
	linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20261030085651.1944-1-laixiangwu@cmss.chinamobile.com>