Article View: linux.kernel.netdev
Article #15039Re: [PATCH net-next v2] net: ethernet: mtk-star-emac: fix device_node leak in mtk_star_probe()
From: Bartosz Golaszewski
Date: Thu, 12 Nov 2026 10:12
Date: Thu, 12 Nov 2026 10:12
22 lines
8953 bytes
8953 bytes
On Thu, Nov 12, 2026 at 11:51:30AM +0800, Xia Yan wrote:
> mtk_star_probe() gets the PHY node from the "phy-handle" property
> with of_parse_phandle(). The helper takes a reference on the node it
> returns. The node is used by of_phy_connect() each time the netdevice
> is opened.
>
> That reference is never dropped. Every error return after the lookup
> leaks it. Unbind leaks it as well: the driver is devm-only and has no
> remove callback.
>
> Release it with a devm action, registered right after the lookup.
> The error paths and the unbind path then drop the node through the
> devm cleanup.
>
> Found during a code review of the OF node handling in ethernet drivers.
>
> Fixes: 8c7bd5a454ff ("net: ethernet: mtk-star-emac: new driver")
> Signed-off-by: Xia Yan <yanxia@cmss.chinamobile.com>
> ---
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Technical Details
Message-ID:
<u6jz3rgrlwhlbhqwgi26lsa2knkwgjws6scbb6e3dq6bkjmudi@hiulukf72wrr>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361700-linux-kernel-netdev=dewy.ruReferences:
<1794455490000.585551.2561101329908158128@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-361700-linux-kernel-netdev=dewy.ru From: brgl@kernel.org (Bartosz Golaszewski) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v2] net: ethernet: mtk-star-emac: fix device_node leak in mtk_star_probe() Date: Thu, 12 Nov 2026 11:12:11 +0100 Organization: Usenet Network Message-ID: <u6jz3rgrlwhlbhqwgi26lsa2knkwgjws6scbb6e3dq6bkjmudi@hiulukf72wrr> References: <1794455490000.585551.2561101329908158128@cmss.chinamobile.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="1059499"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:ZKqmmAuU07duxPcnKdwkzJ3leiI= sha256:M+pf2bQef9smD0bYtWfxes3jc6Pm1jxmg2DKdVDT+RI= sha1:0oLCWJ5ldK+JY/aXk6B5BW31qXA= sha256:mVFie79BL/8EdEgQWEdIIz7KrpLfYGa490M0JdmRzxc= 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 CF2D11141B5; Thu, 12 Nov 2026 13:23:45 +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 dBwOuyoxlOlg; Thu, 12 Nov 2026 13:23:43 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-361700-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id C3E001141AE; Thu, 12 Nov 2026 13:23:34 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 38921E977C; Thu, 12 Nov 2026 10:12:28 +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=1794478336; b=ccTok1x/SXWfmYP/xQHZnSBim25NZMgCabIvPq2DE8w7NzvZONmBS1UeHD7kJZiPbZAT mYjFGcpCqfwqG9Wp5yYfJO5wT+dbaaIhVECthUSReeUPiI0NTV7XoZv+JvVfPjyVh5CvZ RjcmEE/aMohX6gITsyvH3HHGUMlW6DG3eiEUTXlBsrdT3pQt2hjbsyGtFFvgALOJzEB+N Q9cqj5iZapVB7mHNdzihHM3T/8k+8pnQoGfcdQV6NorYiRT8TaHViWkgSZIm8LHnsWE0p cU/SRgUcsoHV0oHjpyzXRBwSiVg9twQBv3/v+PP8nX4G3uO3TKNYtV0krY9LFZd+cgw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794478336; 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=m6vUZ3LR0Bl/r5MeX/A4FbQJiyioDH18V2IC79hgfy0=; b=JLxuc0tFlTBjvN5xO/qlf9pQ6kxkwE6nGRos4KUWjmwdlBazmzgmhJhUpkMbsqkpfD+P U3pI2hMHcJdakOw8wJsHtdvjQVTBSNaNV72q0AJu7S2wat/qkWfIWzEa6O6vBm0FUpkd3 5AJOkKQiavrs6JPGSYQSuROVWHFrq0B2PORdkAgScl5p4WNYF/tDIZ9pY+iF7eobHDl6w rtD1cnFo/Z6OMhNYCjOjdDGGDL3BGip/dh5yboMERUPspgvjP46G+EF+OLqTDuN6cqUb3 rnM9YpyEVxV9z8zslw/lnZK1FU/957b5vYC+P0Q+MJ07zjHlTTDq8pxdXtapbyRy70Q== 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="blh/yOuJ"; 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 045E3606A887; Thu, 12 Nov 2026 10:12:16 +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=blh/yOuJ 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=1794478335; b=vn2EztQNMIuCl0zerIQfNgydwx93nuvs8vVv8/qbhjhMNwAHOsNSjxGpuZ5V0VqxOlBJ d+YJ654xUNgkaHvIPfC9bzi1I05yNc8yneOzJnE7iYfwpwLxBbPeKi0k8A+Qcj/WTY94Q JF58H1mcB1X239JIrgnYdLZG4SWfYKInZYQ5wsWpwEaarXU3Z51zaFnVLrPbMnR1jm96l uR74ordHqDwFh7xQeHYFRGDk7Y2Aj7+2+Q18Wf0o3Duvovk8ScT97BQRNJPs9byJIAJ78 XBi1GpkFf9nTRxmudFiGS3PFgBMbXLjTNfs7mFnhXxrOVIz99L3Ly7CzKLq3PxhZDCw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794478335; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=m6vUZ3LR0Bl/r5MeX/A4FbQJiyioDH18V2IC79hgfy0=; b=QAhdks7ajiEOO78NAf9HnNAtsjfylgg/YIqE9eJV5kg628kgFbab9btdw3wIeo5oEjw9 tGjBa/xMdwXc48EhwwuiuyERk1TSwaWRUIg2RgQ6bH2I2KqNRTTVnqIoc6UWyKVxTova2 zGlUrnyzqpsj++06xas0ubIKsLQuSOy8bi69Q0PnRUUgig0JMnyTzUsUIAFyViFEY/Bga u9WAKpeEZDeVZBh9x/QHZtUYyHqQYBWjBdwagevEhp9Zd6ntLtxXIWM4QzCA7DUMhvrNk K7QgCRcQOyqMq3eS5od5DJtPu9VfJSXQftQEHKvQHOuEGNxD4alwAvyuUyUd5SsJK/w== 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="blh/yOuJ"; 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 UTF8SMTPS id 254CB606A337; Thu, 12 Nov 2026 10:12:15 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 1BC8E1F00A05; Thu, 12 Nov 2026 10:12:13 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794478335; bh=m6vUZ3LR0Bl/r5MeX/A4FbQJiyioDH18V2IC79hgfy0=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=blh/yOuJpn/OjkRt/062TkdjYc3SCnLweis40rnFbiSAh8WIt5dI8Vnr+GMbVMXf3 qs7/kjJWcx6GPKbXJlXfrCXDfA87LEp0HrrhthbY+o3P77jKRkzZsEWCpo6STNpZ+H eMlK7zwt59UbK/QMW8Ug/zjh8U/uMiYiHRckEUExUJI5Hnok6vINBYRopm2JTQ8aNH Z0fpeTMB/uwTffFrp6HC+bxWB9Ihle+6TP6vaKwpCwbkzN9/xIdhZx4wiWBtI5uKOs 6eTaDbdPmHGA8OhkdEPp3qN5+Loipi2EvhKkWJQpr1kZ90Ov6nVYhEmbvjhcTlaSoh gGBZ/nORmaVoA== X-Cc: netdev@vger.kernel.org, Felix Fietkau <nbd@nbd.name>, Lorenzo Bianconi <lorenzo@kernel.org>, 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>, Matthias Brugger <matthias.bgg@gmail.com>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, Yanqing Wang <ot_yanqing.wang@mediatek.com>, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, yana06070@163.com 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: <1794455490000.585551.2561101329908158128@cmss.chinamobile.com>