linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] thermal: common: free the mem allocated when out of use
@ 2016-01-12 10:37 Bai Ping
  2016-01-12 12:00 ` Punit Agrawal
  0 siblings, 1 reply; 2+ messages in thread
From: Bai Ping @ 2016-01-12 10:37 UTC (permalink / raw)
  To: edubezval, rui.zhang; +Cc: linux-pm

The memory resource allocated for thermal_zone_device
should be freed when thermal_zone_device registers failed
or the thermal_zone_device unregistered.

Signed-off-by: Bai Ping <ping.bai@nxp.com>
---
 drivers/thermal/thermal_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 7f7a3ca..1a9cf31 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -2012,6 +2012,7 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
 unregister:
 	release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id);
 	device_unregister(&tz->device);
+	kfree(tz);
 	return ERR_PTR(result);
 }
 EXPORT_SYMBOL_GPL(thermal_zone_device_register);
@@ -2081,6 +2082,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
 	idr_destroy(&tz->idr);
 	mutex_destroy(&tz->lock);
 	device_unregister(&tz->device);
+	kfree(tz);
 	return;
 }
 EXPORT_SYMBOL_GPL(thermal_zone_device_unregister);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] thermal: common: free the mem allocated when out of use
  2016-01-12 10:37 [PATCH] thermal: common: free the mem allocated when out of use Bai Ping
@ 2016-01-12 12:00 ` Punit Agrawal
  0 siblings, 0 replies; 2+ messages in thread
From: Punit Agrawal @ 2016-01-12 12:00 UTC (permalink / raw)
  To: Bai Ping; +Cc: edubezval, rui.zhang, linux-pm

Bai Ping <ping.bai@nxp.com> writes:

> The memory resource allocated for thermal_zone_device
> should be freed when thermal_zone_device registers failed
> or the thermal_zone_device unregistered.
>
> Signed-off-by: Bai Ping <ping.bai@nxp.com>
> ---
>  drivers/thermal/thermal_core.c | 2 ++
>  1 file changed, 2 insertions(+)
>

Good catch!

     Reviewed-by: Punit Agrawal <punit.agrawal@arm.com>

I hope Rui can pick this up for the rc releases.

Thanks!

> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index 7f7a3ca..1a9cf31 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -2012,6 +2012,7 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
>  unregister:
>  	release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id);
>  	device_unregister(&tz->device);
> +	kfree(tz);
>  	return ERR_PTR(result);
>  }
>  EXPORT_SYMBOL_GPL(thermal_zone_device_register);
> @@ -2081,6 +2082,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
>  	idr_destroy(&tz->idr);
>  	mutex_destroy(&tz->lock);
>  	device_unregister(&tz->device);
> +	kfree(tz);
>  	return;
>  }
>  EXPORT_SYMBOL_GPL(thermal_zone_device_unregister);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-01-12 12:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-12 10:37 [PATCH] thermal: common: free the mem allocated when out of use Bai Ping
2016-01-12 12:00 ` Punit Agrawal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).