Skip to content

Commit

Permalink
platform/x86: dell-wmi-sysman: Make it safe to call exit_foo_attribut…
Browse files Browse the repository at this point in the history
…es() multiple times

[ Upstream commit 2d0c418 ]

During some of the error-exit paths it is possible that
release_attributes_data() will get called multiple times,
which results in exit_foo_attributes() getting called multiple
times.

Make it safe to call exit_foo_attributes() multiple times,
avoiding double-free()s in this case.

Note that release_attributes_data() really should only be called
once during error-exit paths. This will be fixed in a separate patch
and it is good to have the exit_foo_attributes() functions modified
this way regardless.

Fixes: e8a60aa ("platform/x86: Introduce support for Systems Management Driver over WMI for Dell Systems")
Cc: Divya Bharathi <Divya_Bharathi@dell.com>
Cc: Mario Limonciello <mario.limonciello@dell.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210321115901.35072-4-hdegoede@redhat.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
jwrdegoede authored and gregkh committed Mar 30, 2021
1 parent 2286f94 commit 2e6468a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/platform/x86/dell-wmi-sysman/enum-attributes.c
Expand Up @@ -185,5 +185,8 @@ void exit_enum_attributes(void)
sysfs_remove_group(wmi_priv.enumeration_data[instance_id].attr_name_kobj,
&enumeration_attr_group);
}
wmi_priv.enumeration_instances_count = 0;

kfree(wmi_priv.enumeration_data);
wmi_priv.enumeration_data = NULL;
}
3 changes: 3 additions & 0 deletions drivers/platform/x86/dell-wmi-sysman/int-attributes.c
Expand Up @@ -175,5 +175,8 @@ void exit_int_attributes(void)
sysfs_remove_group(wmi_priv.integer_data[instance_id].attr_name_kobj,
&integer_attr_group);
}
wmi_priv.integer_instances_count = 0;

kfree(wmi_priv.integer_data);
wmi_priv.integer_data = NULL;
}
3 changes: 3 additions & 0 deletions drivers/platform/x86/dell-wmi-sysman/passobj-attributes.c
Expand Up @@ -183,5 +183,8 @@ void exit_po_attributes(void)
sysfs_remove_group(wmi_priv.po_data[instance_id].attr_name_kobj,
&po_attr_group);
}
wmi_priv.po_instances_count = 0;

kfree(wmi_priv.po_data);
wmi_priv.po_data = NULL;
}
3 changes: 3 additions & 0 deletions drivers/platform/x86/dell-wmi-sysman/string-attributes.c
Expand Up @@ -155,5 +155,8 @@ void exit_str_attributes(void)
sysfs_remove_group(wmi_priv.str_data[instance_id].attr_name_kobj,
&str_attr_group);
}
wmi_priv.str_instances_count = 0;

kfree(wmi_priv.str_data);
wmi_priv.str_data = NULL;
}

0 comments on commit 2e6468a

Please sign in to comment.