Re: [PATCH net-next v2] net: ethernet: mtk-star-emac: fix device_node leak in mtk_star_probe()

From
Lorenzo Bianconi <lorenzo@kernel.org>
Date
2026-11-12 11:04:31
Also in
linux-arm-kernel, linux-mediatek, lkml
Reply to
Bartosz Golaszewski, 2026-11-12
On Thu, Nov 12, 2026 at 11:51:30AM +0800, Xia Yan wrote:
quoted
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 <redacted>
---
Reviewed-by: Bartosz Golaszewski <redacted> 
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>

Attachments

Thread (6 messages) 6 messages, 5 authors, last reply 2d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help