diff mbox

thermal: common: free the mem allocated when out of use

Message ID 1452595043-7239-1-git-send-email-ping.bai@nxp.com (mailing list archive)
State Accepted, archived
Delegated to: Zhang Rui
Headers show

Commit Message

Jacky Bai Jan. 12, 2016, 10:37 a.m. UTC
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(+)

Comments

Punit Agrawal Jan. 12, 2016, noon UTC | #1
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);
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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);