thermal/drivers/airoha: Fix a device node reference leak in airoha_thermal_probe()
PATCH 1/1 thermal/drivers/airoha: Fix a device node reference leak in airoha_thermal_probe()
In airoha_thermal_probe() function, chip-scu node is acquired through of_parse_phandle(), but it fails to release this reference if syscon_node_to_regmap() returns an error.
Add the missing of_node_put() call to the error path to ensure the reference count is properly decremented.
--- drivers/thermal/airoha_thermal.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/thermal/airoha_thermal.c +3 -1
@@ -431,8 +431,10 @@ static int airoha_thermal_probe(struct platform_device *pdev)return -EINVAL ; priv->chip_scu =syscon_node_to_regmap (chip_scu_np); -if (IS_ERR (priv->chip_scu)) +if (IS_ERR (priv->chip_scu)) { +of_node_put (chip_scu_np);return PTR_ERR (priv->chip_scu); + }of_address_to_resource (chip_scu_np,0 , &priv->scu_adc_res);of_node_put (chip_scu_np);
---
base-commit: a0c666c25aeefd16f4b088c6549a6fb6b65a8a1d
change-id: 20260123-airoha-ccd6a16a6ef6
Best regards,
Signature · 1 line
Felix Gu <[email protected]>
Hi Felix,
Quoted 18 lines · Felix Gu
In
airoha_thermal_probe()function, chip-scu node is acquired throughof_parse_phandle(), but it fails to release this reference ifsyscon_node_to_regmap()returns an error.
Add the missingof_node_put()call to the error path to ensure the reference count is properly decremented.Fixes 42de37f40e1b ("thermal/drivers: Add support for Airoha EN7581 thermal sensor")Signed-off-by Felix Gu <[email protected]>--- drivers/thermal/airoha_thermal.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/thermal/airoha_thermal.c +0
-0@@ -431,8 +431,10 @@ static int airoha_thermal_probe(struct platform_device *pdev)return -EINVAL ;
drivers/thermal/airoha_thermal.c static int airoha_thermal_probe(struct platform_device *pdev) · line 440
Quoted 10 lines
drivers/thermal/airoha_thermal.c +3
-1priv->chip_scu =syscon_node_to_regmap (chip_scu_np); -if (IS_ERR (priv->chip_scu)) +if (IS_ERR (priv->chip_scu)) { +of_node_put (chip_scu_np);return PTR_ERR (priv->chip_scu); + }of_address_to_resource (chip_scu_np,0 , &priv->scu_adc_res);of_node_put (chip_scu_np);
Thank you for the patch, LGTM.