diff mbox series

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

Message ID 20241212-drivers_fix-v1-1-a3fbb0bf6846@quicinc.com (mailing list archive)
State New
Delegated to: Netdev Maintainers
Headers show
Series net: Fix 2 OF device node refcount leakage issues | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 7 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Zijun Hu Dec. 12, 2024, 3:06 p.m. UTC
From: Zijun Hu <quic_zijuhu@quicinc.com>

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@quicinc.com>
---
 drivers/net/pse-pd/tps23881.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

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;