Skip to contentSkip to conversation

hwmon: Fix resource leaks for device_node

PATCH Applied Felix Gu 3 participants 6 messages Jan 15

Subsystems (2)
lore
Share & tools
lore

Felix Gu

author
#0 lore raw

cover hwmon: Fix resource leaks for device_node

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

---
Felix Gu (2):
hwmon: emc2305: Fix a resource leak in emc2305_of_parse_pwm_child
hwmon: nct7353: Fix a resource leak in nct7363_present_pwm_fanin

 drivers/hwmon/emc2305.c | 1 +
 drivers/hwmon/nct7363.c | 1 +
 2 files changed, 2 insertions(+)

---
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
change-id: 20260115-hwmon-fixes-3d29ded39dbf

Best regards,

Signature · 1 line
Felix Gu <[email protected]>
author
#1 lore raw

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

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.

---
 drivers/hwmon/emc2305.c | 1 +
 1 file changed, 1 insertion(+)
drivers/hwmon/emc2305.c +1 -0
index 8f80a39574f3..64b213e1451e 100644
@@ -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;
 }
 
Signature · 1 line
2.43.0
maintainer Applied
#2 lore raw

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

Quoted 6 lines · Felix Gu

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.

Applied.

Thanks,
Guenter

author
#3 lore raw

PATCH 2/2 hwmon: nct7363: Fix a resource leak in nct7363_present_pwm_fanin

In reply to Felix Gu

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.

---
 drivers/hwmon/nct7363.c | 1 +
 1 file changed, 1 insertion(+)
drivers/hwmon/nct7363.c +1 -0
index 4946d59ff807..20f14d5e0c94 100644
@@ -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]);
Signature · 1 line
2.43.0
maintainer Applied
#4 lore raw

Re: [PATCH 2/2] hwmon: nct7363: Fix a resource leak in nct7363_present_pwm_fanin

Quoted 6 lines · Felix Gu

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.

Applied.

Thanks,
Guenter

#5 lore raw
In reply to Felix Gu

See also:
* hwmon: (emc2305) Fix a resource leak in emc2305_of_parse_pwm_child
https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git/commit/?h=hwmon-next&id=6b3a30846c23af1b36f1c1726e6ab5d6c9aa90cc

* hwmon: (nct7363) Fix a resource leak in nct7363_present_pwm_fanin
https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git/commit/?h=hwmon-next&id=e59f0a584366b775e1dee39e183d8b37e6c0443d

I wonder why these commits did not get the tag “Fixes” together with the “stable” annotation.

Regards,
Markus