mirror of
https://github.com/torvalds/linux.git
synced 2024-11-29 15:41:36 +00:00
platform/x86: dell-pc: avoid double free and invalid unregistration
If platform_profile_register() fails it does kfree(thermal_handler) and
leaves the pointer value around.
Any call to thermal_cleanup() will try to kfree(thermal_handler) again.
This will happen right away in dell_init().
In addition, platform_profile_remove() will be called although no
profile is registered.
NULL out the thermal_handler, so thermal_cleanup() avoids the double free.
Fixes: 996ad41298
("platform/x86: dell-pc: Implement platform_profile")
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Lyndon Sanche <lsanche@lyndeno.ca>
Link: https://lore.kernel.org/r/20240604-dell-pc-double-free-v1-1-6d81255b2a44@weissschuh.net
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
This commit is contained in:
parent
4894c364d5
commit
dd637f5cd5
@ -261,8 +261,10 @@ static int thermal_init(void)
|
||||
|
||||
/* Clean up if failed */
|
||||
ret = platform_profile_register(thermal_handler);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
kfree(thermal_handler);
|
||||
thermal_handler = NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user