]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
thermal: core: Fix resources release in error paths in thermal_zone_device_register()
authorChristophe Jaillet <christophe.jaillet@wanadoo.fr>
Tue, 8 Aug 2017 14:39:54 +0000 (16:39 +0200)
committerZhang Rui <rui.zhang@intel.com>
Fri, 11 Aug 2017 03:34:07 +0000 (11:34 +0800)
commit9d9ca1f9f04cf1d20427528cd3b3d05ebad47547
tree70384f8f55ac24f69d766409c93b0aa4a58aac3b
parent6a6cd25b58dc8ce2fbded8dd83bfa7d48f06f97d
thermal: core: Fix resources release in error paths in thermal_zone_device_register()

Reorder error handling code in order to fix some resources leaks in some
cases:
   - 'tz' would leak if 'thermal_zone_create_device_groups()' fails
   - memory allocated by 'thermal_zone_create_device_groups()' would leak
     if 'device_register()' fails

With this patch, we now have 2 error handling paths: one before
'device_register()', and one after it.
This is needed because some resources are released in 'thermal_release()'.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
drivers/thermal/thermal_core.c