Skip to content

Commit 23dcd74

Browse files
committed
platform/x86: think-lmi: Move kfree(setting->possible_values) to tlmi_attr_setting_release()
We must not free the possible_values string before we have called sysfs_remove_group(kobj, &tlmi_attr_group) otherwise there is a race where a sysfs read of possible_values could reference the free-ed memory. Move the kfree(setting->possible_values) together with the free of the actual tlmi_attr_setting struct to avoid this race. Signed-off-by: Hans de Goede <[email protected]>
1 parent 0fdf10e commit 23dcd74

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/platform/x86/think-lmi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ static void tlmi_attr_setting_release(struct kobject *kobj)
626626
{
627627
struct tlmi_attr_setting *setting = to_tlmi_attr_setting(kobj);
628628

629+
kfree(setting->possible_values);
629630
kfree(setting);
630631
}
631632

@@ -654,7 +655,6 @@ static void tlmi_release_attr(void)
654655
/* Attribute structures */
655656
for (i = 0; i < TLMI_SETTINGS_COUNT; i++) {
656657
if (tlmi_priv.setting[i]) {
657-
kfree(tlmi_priv.setting[i]->possible_values);
658658
sysfs_remove_group(&tlmi_priv.setting[i]->kobj, &tlmi_attr_group);
659659
kobject_put(&tlmi_priv.setting[i]->kobj);
660660
}

0 commit comments

Comments
 (0)