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 <hdegoede@redhat.com>
{
struct tlmi_attr_setting *setting = to_tlmi_attr_setting(kobj);
+ kfree(setting->possible_values);
kfree(setting);
}
/* Attribute structures */
for (i = 0; i < TLMI_SETTINGS_COUNT; i++) {
if (tlmi_priv.setting[i]) {
- kfree(tlmi_priv.setting[i]->possible_values);
sysfs_remove_group(&tlmi_priv.setting[i]->kobj, &tlmi_attr_group);
kobject_put(&tlmi_priv.setting[i]->kobj);
}