[PATCH 1/2] hwmon: emc2305: Fix a resource leak in emc2305_of_parse_pwm_child

Felix Gu posted 2 patches 3 weeks, 4 days ago
[PATCH 1/2] hwmon: emc2305: Fix a resource leak in emc2305_of_parse_pwm_child
Posted by Felix Gu 3 weeks, 4 days ago
When calling of_parse_phandle_with_args(), the caller is responsible
to call of_node_put() to release the reference of device node.
In emc2305_of_parse_pwm_child, it does not release the reference,
causing a resource leak.

Signed-off-by: Felix Gu <gu_0233@qq.com>
---
 drivers/hwmon/emc2305.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/hwmon/emc2305.c b/drivers/hwmon/emc2305.c
index 8f80a39574f3..64b213e1451e 100644
--- a/drivers/hwmon/emc2305.c
+++ b/drivers/hwmon/emc2305.c
@@ -578,6 +578,7 @@ static int emc2305_of_parse_pwm_child(struct device *dev,
 		data->pwm_output_mask |= EMC2305_OPEN_DRAIN << ch;
 	}
 
+	of_node_put(args.np);
 	return 0;
 }
 
-- 
2.43.0
Re: [PATCH 1/2] hwmon: emc2305: Fix a resource leak in emc2305_of_parse_pwm_child
Posted by Guenter Roeck 3 weeks, 4 days ago
On Thu, Jan 15, 2026 at 09:51:48PM +0800, Felix Gu wrote:
> When calling of_parse_phandle_with_args(), the caller is responsible
> to call of_node_put() to release the reference of device node.
> In emc2305_of_parse_pwm_child, it does not release the reference,
> causing a resource leak.
> 
> Signed-off-by: Felix Gu <gu_0233@qq.com>

Applied.

Thanks,
Guenter