Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Thermal/int340x: Fix memleak for aux trip

When thermal zone device register fails or on module exit, the memory
for aux_trip is not freed. This change fixes this issue.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>

authored by

Srinivas Pandruvada and committed by
Eduardo Valentin
d5bce867 78045bfe

+6 -4
+6 -4
drivers/thermal/int340x_thermal/int340x_thermal_zone.c
··· 208 208 trip_cnt, GFP_KERNEL); 209 209 if (!int34x_thermal_zone->aux_trips) { 210 210 ret = -ENOMEM; 211 - goto free_mem; 211 + goto err_trip_alloc; 212 212 } 213 213 trip_mask = BIT(trip_cnt) - 1; 214 214 int34x_thermal_zone->aux_trip_nr = trip_cnt; ··· 248 248 0, 0); 249 249 if (IS_ERR(int34x_thermal_zone->zone)) { 250 250 ret = PTR_ERR(int34x_thermal_zone->zone); 251 - goto free_lpat; 251 + goto err_thermal_zone; 252 252 } 253 253 254 254 return int34x_thermal_zone; 255 255 256 - free_lpat: 256 + err_thermal_zone: 257 257 acpi_lpat_free_conversion_table(int34x_thermal_zone->lpat_table); 258 - free_mem: 258 + kfree(int34x_thermal_zone->aux_trips); 259 + err_trip_alloc: 259 260 kfree(int34x_thermal_zone); 260 261 return ERR_PTR(ret); 261 262 } ··· 267 266 { 268 267 thermal_zone_device_unregister(int34x_thermal_zone->zone); 269 268 acpi_lpat_free_conversion_table(int34x_thermal_zone->lpat_table); 269 + kfree(int34x_thermal_zone->aux_trips); 270 270 kfree(int34x_thermal_zone); 271 271 } 272 272 EXPORT_SYMBOL_GPL(int340x_thermal_zone_remove);