[PATCH net 1/2] net: pse-pd: tps23881: Fix device node refcount leakage in tps23881_get_of_channels()

From: Zijun Hu
Date: Thu Dec 12 2024 - 10:12:41 EST


From: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>

tps23881_get_of_channels() invokes of_find_node_by_name(@priv->np, ...)
and the callee will put OF device node @priv->np refcount, but the caller
does not compensate the refcount before the invocation, so causes the node
refcount leakage.

Fix by of_node_get(@priv->np) before the invocation.

Fixes: 20e6d190ffe1 ("net: pse-pd: Add TI TPS23881 PSE controller driver")
Signed-off-by: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
---
drivers/net/pse-pd/tps23881.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/net/pse-pd/tps23881.c b/drivers/net/pse-pd/tps23881.c
index 5c4e88be46ee3316330e26a68d06540ff1db86ff..f5c04dd5be379f7b9697e067a32d59028f446088 100644
--- a/drivers/net/pse-pd/tps23881.c
+++ b/drivers/net/pse-pd/tps23881.c
@@ -216,6 +216,7 @@ tps23881_get_of_channels(struct tps23881_priv *priv,
if (!priv->np)
return -EINVAL;

+ of_node_get(priv->np);
channels_node = of_find_node_by_name(priv->np, "channels");
if (!channels_node)
return -EINVAL;

--
2.34.1