[PATCH AUTOSEL 6.19-6.18] hwmon: (nct7363) Fix a resource leak in nct7363_present_pwm_fanin

Sasha Levin
2026-02-14T01:06:35Z

From: Felix Gu <gu_0233@qq.com>

[ Upstream commit 4923bbff0bcffe488b3aa76829c829bd15b02585 ]

When calling of_parse_phandle_with_args(), the caller is responsible
to call of_node_put() to release the reference of device node.
In nct7363_present_pwm_fanin, it does not release the reference,
causing a resource leak.

Signed-off-by: Felix Gu <gu_0233@qq.com>
Link: https://lore.kernel.org/r/tencent_9717645269E4C07D3D131F52201E12E5E10A@qq.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

LLM Generated explanations, may be completely bogus:

The driver was first included in v6.13. This means it's only available
in relatively recent stable trees (6.13.y and later, if those are
maintained as stable). It won't be applicable to older LTS trees like
6.6.y or 6.1.y since the driver doesn't exist there.

### User Impact

For systems using the NCT7363Y hardware monitoring chip (common in
server/embedded platforms), this leak occurs during driver probe. While
a single leak may be small, in systems with deferred probing or module
load/unload cycles, it can accumulate. The fix ensures proper cleanup.

### Conclusion

This is a textbook stable backport candidate:
- **Obviously correct**: Standard `of_node_put()` pattern used thousands
of times in the kernel
- **Fixes a real bug**: Resource leak on every probe
- **Minimal risk**: 1 line addition, correctly placed
- **Small and contained**: Single file, single function

The only caveat is that the driver is relatively new (v6.13+), so the
backport only applies to recent stable trees. But for those trees where
it applies, this is clearly appropriate.

**YES**

drivers/hwmon/nct7363.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/hwmon/nct7363.c b/drivers/hwmon/nct7363.c
index 71cef794835df..47fc1b4a0f3f9 100644
--- a/drivers/hwmon/nct7363.c
+++ b/drivers/hwmon/nct7363.c
@@ -349,6 +349,7 @@ static int nct7363_present_pwm_fanin(struct device *dev,
if (ret)
return ret;

+ of_node_put(args.np);
if (args.args[0] >= NCT7363_PWM_COUNT)
return -EINVAL;
data->pwm_mask |= BIT(args.args[0]);
--
2.51.0