thermal: common: free the mem allocated when out of use
PATCH 1/1 thermal: common: free the mem allocated when out of use
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 <[email protected]>
--- drivers/thermal/thermal_core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/thermal/thermal_core.c +2 -0
@@ -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);
Signature · 1 line
1.9.1
Quoted 9 lines · Bai Ping
The memory resource allocated for
thermal_zone_deviceshould be freed whenthermal_zone_deviceregisters failed or thethermal_zone_deviceunregistered.Signed-off-by Bai Ping <[email protected]>--- drivers/thermal/thermal_core.c | 2 ++ 1 file changed, 2 insertions(+)
Good catch!
Reviewed-by Punit Agrawal <[email protected]>
I hope Rui can pick this up for the rc releases.
Thanks!
Quoted 20 lines
drivers/thermal/thermal_core.c +2
-0@@ -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);