Unverified Commit dd637f5c authored by Thomas Weißschuh's avatar Thomas Weißschuh Committed by Ilpo Järvinen
Browse files

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: 996ad412 ("platform/x86: dell-pc: Implement platform_profile")
Signed-off-by: default avatarThomas Weißschuh <linux@weissschuh.net>
Reviewed-by: default avatarLyndon Sanche <lsanche@lyndeno.ca>
Link: https://lore.kernel.org/r/20240604-dell-pc-double-free-v1-1-6d81255b2a44@weissschuh.net


Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
parent 4894c364
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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;
}