Skip to contentSkip to conversation

thermal: imx: Add missing of_node_put()

PATCH Superseded Anson Huang 2 participants 3 messages Mar 26, 2020

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thermal: imx: Add missing of_node_put()

After finishing using cpu node got from of_get_cpu_node(), of_node_put() needs to be called.

---
 drivers/thermal/imx_thermal.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/thermal/imx_thermal.c +7 -3
index e761c9b..f7b970d 100644
@@ -649,7 +649,7 @@ MODULE_DEVICE_TABLE(of, of_imx_thermal_match);
 static int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data)
 {
 	struct device_node *np;
-	int ret;
+	int ret = 0;
 
 	data->policy = cpufreq_cpu_get(0);
 	if (!data->policy) {
@@ -664,11 +664,15 @@ static int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data)
 		if (IS_ERR(data->cdev)) {
 			ret = PTR_ERR(data->cdev);
 			cpufreq_cpu_put(data->policy);
-			return ret;
+			goto put_node;
 		}
 	}
 
-	return 0;
+put_node:
+	if (np)
+		of_node_put(np);
+
+	return ret;
 }
 
 static void imx_thermal_unregister_legacy_cooling(struct imx_thermal_data *data)
Signature · 1 line
2.7.4
#1 lore raw
Quoted 21 lines · Anson Huang

After finishing using cpu node got from of_get_cpu_node(), of_node_put() needs to be called.

drivers/thermal/imx_thermal.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)

(quoted diff) +0 -0

b/drivers/thermal/imx_thermal.c index e761c9b..f7b970d 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -649,7 +649,7 @@ MODULE_DEVICE_TABLE(of, of_imx_thermal_match); static int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data)
{ struct device_node *np; - int ret; + int ret = 0;

data->policy = cpufreq_cpu_get(0); if (!data->policy) { @@ -664,11 +664,15 @@ static int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data) if (IS_ERR(data->cdev)) { ret =
PTR_ERR(data->cdev); cpufreq_cpu_put(data->policy); - return
ret; + goto put_node; } }

Review

Quoted 1 line
(quoted diff) +0 -1
-	return 0; +put_node: +	if (np) +		of_node_put(np);

of_node_put() is already checking if 'np' is NULL.

Quoted 5 lines

+ + return ret; }

static void imx_thermal_unregister_legacy_cooling(struct imx_thermal_data *data)

Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#2 lore raw

Hi, Daniel

Quoted 23 lines

Subject: Re: [PATCH] thermal: imx: Add missing of_node_put()

Quoted 10 lines · Anson Huang

After finishing using cpu node got from of_get_cpu_node(), of_node_put() needs to be called.

drivers/thermal/imx_thermal.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)

(quoted diff) +0 -0

b/drivers/thermal/imx_thermal.c index e761c9b..f7b970d 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c

@@

Quoted 1 line

-649,7 +649,7 @@ MODULE_DEVICE_TABLE(of, of_imx_thermal_match);

static

Quoted 7 lines

int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data)
{ struct device_node *np; - int ret; + int ret = 0;

data->policy = cpufreq_cpu_get(0); if (!data->policy) { @@ -664,11 +664,15 @@ static int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data) if (IS_ERR(data->cdev)) { ret = PTR_ERR(data->cdev); cpufreq_cpu_put(data->policy); -

Quoted 6 lines

return

Review

Quoted 3 lines

ret; + goto put_node; } }

(quoted diff) +0 -1
-	return 0; +put_node: +	if (np) +		of_node_put(np);

of_node_put() is already checking if 'np' is NULL.

OK, I will remove the checking of if 'np' is NULL.

Thanks,
Anson