* [PATCH v2 0/7] platform/x86: dell-wmi-sysman: Various error-handling and robustness fixes
@ 2021-03-21 11:58 Hans de Goede
2021-03-21 11:58 ` [PATCH v2 1/7] platform/x86: dell-wmi-sysman: Fix crash caused by calling kset_unregister twice Hans de Goede
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Hans de Goede @ 2021-03-21 11:58 UTC (permalink / raw)
To: Mark Gross, Andy Shevchenko
Cc: Hans de Goede, Mario Limonciello, Divya Bharathi,
Alexander Naumann, platform-driver-x86
Hi All,
There have been several bug-reports about crashes related to the
dell-wmi-sysman module:
https://bugzilla.redhat.com/show_bug.cgi?id=1936171
https://bugzilla.kernel.org/show_bug.cgi?id=211895
https://bugs.archlinux.org/task/69702
Here is v2 of my series with a bunch of fixes for NULL pointer derefs,
double-frees, etc. which fixes this.
New in v2:
-New patch: "platform/x86: dell-wmi-sysman: Fix crash caused by calling
kset_unregister twice" which addresses the direct-cause of
the crash. Note that the crash was already fixed in v1 because
that removed the code-path where kset_unregister ended up being
called twice.
-Dropped: "platform/x86: dell-wmi-sysman: Make init_bios_attributes()
ACPI object parsing more robust". This needs more testing / discussion
and is not necessary to fix the boot-failure which people are seeing.
Regards,
Hans
Hans de Goede (7):
platform/x86: dell-wmi-sysman: Fix crash caused by calling
kset_unregister twice
platform/x86: dell-wmi-sysman: Fix possible NULL pointer deref on exit
platform/x86: dell-wmi-sysman: Make it safe to call
exit_foo_attributes() multiple times
platform/x86: dell-wmi-sysman: Fix release_attributes_data() getting
called twice on init_bios_attributes() failure
platform/x86: dell-wmi-sysman: Cleanup sysman_init() error-exit
handling
platform/x86: dell-wmi-sysman: Make sysman_init() return -ENODEV of
the interfaces are not found
platform/x86: dell-wmi-sysman: Cleanup
create_attributes_level_sysfs_files()
.../dell/dell-wmi-sysman/enum-attributes.c | 3 +
.../x86/dell/dell-wmi-sysman/int-attributes.c | 3 +
.../dell/dell-wmi-sysman/passobj-attributes.c | 3 +
.../dell/dell-wmi-sysman/string-attributes.c | 3 +
.../x86/dell/dell-wmi-sysman/sysman.c | 84 +++++++------------
5 files changed, 44 insertions(+), 52 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/7] platform/x86: dell-wmi-sysman: Fix crash caused by calling kset_unregister twice
2021-03-21 11:58 [PATCH v2 0/7] platform/x86: dell-wmi-sysman: Various error-handling and robustness fixes Hans de Goede
@ 2021-03-21 11:58 ` Hans de Goede
2021-03-21 11:58 ` [PATCH v2 2/7] platform/x86: dell-wmi-sysman: Fix possible NULL pointer deref on exit Hans de Goede
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Hans de Goede @ 2021-03-21 11:58 UTC (permalink / raw)
To: Mark Gross, Andy Shevchenko
Cc: Hans de Goede, Mario Limonciello, Divya Bharathi,
Alexander Naumann, platform-driver-x86
On some system the WMI GUIDs used by dell-wmi-sysman are present but there
are no enum type attributes, this causes init_bios_attributes() to return
-ENODEV, after which sysman_init() does a "goto fail_create_group" and then
calls release_attributes_data().
release_attributes_data() calls kset_unregister(wmi_priv.main_dir_kset);
but before this commit it was missing a "wmi_priv.main_dir_kset = NULL;"
statement; and after calling release_attributes_data() the sysman_init()
error handling does this:
if (wmi_priv.main_dir_kset) {
kset_unregister(wmi_priv.main_dir_kset);
wmi_priv.main_dir_kset = NULL;
}
Which causes a second kset_unregister(wmi_priv.main_dir_kset), leading to
a double-free, which causes a crash.
Add the missing "wmi_priv.main_dir_kset = NULL;" statement to
release_attributes_data() to fix this double-free crash.
Fixes: e8a60aa7404b ("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>
---
drivers/platform/x86/dell/dell-wmi-sysman/sysman.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
index cb81010ba1a2..c1997db74cca 100644
--- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
+++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
@@ -388,6 +388,7 @@ static void release_attributes_data(void)
if (wmi_priv.main_dir_kset) {
destroy_attribute_objs(wmi_priv.main_dir_kset);
kset_unregister(wmi_priv.main_dir_kset);
+ wmi_priv.main_dir_kset = NULL;
}
mutex_unlock(&wmi_priv.mutex);
--
2.30.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/7] platform/x86: dell-wmi-sysman: Fix possible NULL pointer deref on exit
2021-03-21 11:58 [PATCH v2 0/7] platform/x86: dell-wmi-sysman: Various error-handling and robustness fixes Hans de Goede
2021-03-21 11:58 ` [PATCH v2 1/7] platform/x86: dell-wmi-sysman: Fix crash caused by calling kset_unregister twice Hans de Goede
@ 2021-03-21 11:58 ` Hans de Goede
2021-03-21 11:58 ` [PATCH v2 3/7] platform/x86: dell-wmi-sysman: Make it safe to call exit_foo_attributes() multiple times Hans de Goede
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Hans de Goede @ 2021-03-21 11:58 UTC (permalink / raw)
To: Mark Gross, Andy Shevchenko
Cc: Hans de Goede, Mario Limonciello, Divya Bharathi,
Alexander Naumann, platform-driver-x86
It is possible for release_attributes_data() to get called when the
main_dir_kset has not been created yet, move the removal of the bios-reset
sysfs attr to under a if (main_dir_kset) check to avoid a NULL pointer
deref.
Fixes: e8a60aa7404b ("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>
Reported-by: Alexander Naumann <alexandernaumann@gmx.de>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/platform/x86/dell/dell-wmi-sysman/sysman.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
index c1997db74cca..8b251b2c37a2 100644
--- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
+++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
@@ -225,12 +225,6 @@ static int create_attributes_level_sysfs_files(void)
return ret;
}
-static void release_reset_bios_data(void)
-{
- sysfs_remove_file(&wmi_priv.main_dir_kset->kobj, &reset_bios.attr);
- sysfs_remove_file(&wmi_priv.main_dir_kset->kobj, &pending_reboot.attr);
-}
-
static ssize_t wmi_sysman_attr_show(struct kobject *kobj, struct attribute *attr,
char *buf)
{
@@ -373,8 +367,6 @@ static void destroy_attribute_objs(struct kset *kset)
*/
static void release_attributes_data(void)
{
- release_reset_bios_data();
-
mutex_lock(&wmi_priv.mutex);
exit_enum_attributes();
exit_int_attributes();
@@ -386,12 +378,13 @@ static void release_attributes_data(void)
wmi_priv.authentication_dir_kset = NULL;
}
if (wmi_priv.main_dir_kset) {
+ sysfs_remove_file(&wmi_priv.main_dir_kset->kobj, &reset_bios.attr);
+ sysfs_remove_file(&wmi_priv.main_dir_kset->kobj, &pending_reboot.attr);
destroy_attribute_objs(wmi_priv.main_dir_kset);
kset_unregister(wmi_priv.main_dir_kset);
wmi_priv.main_dir_kset = NULL;
}
mutex_unlock(&wmi_priv.mutex);
-
}
/**
--
2.30.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 3/7] platform/x86: dell-wmi-sysman: Make it safe to call exit_foo_attributes() multiple times
2021-03-21 11:58 [PATCH v2 0/7] platform/x86: dell-wmi-sysman: Various error-handling and robustness fixes Hans de Goede
2021-03-21 11:58 ` [PATCH v2 1/7] platform/x86: dell-wmi-sysman: Fix crash caused by calling kset_unregister twice Hans de Goede
2021-03-21 11:58 ` [PATCH v2 2/7] platform/x86: dell-wmi-sysman: Fix possible NULL pointer deref on exit Hans de Goede
@ 2021-03-21 11:58 ` Hans de Goede
2021-03-21 11:58 ` [PATCH v2 4/7] platform/x86: dell-wmi-sysman: Fix release_attributes_data() getting called twice on init_bios_attributes() failure Hans de Goede
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Hans de Goede @ 2021-03-21 11:58 UTC (permalink / raw)
To: Mark Gross, Andy Shevchenko
Cc: Hans de Goede, Mario Limonciello, Divya Bharathi,
Alexander Naumann, platform-driver-x86
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: e8a60aa7404b ("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>
---
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c | 3 +++
drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c | 3 +++
drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c | 3 +++
drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.c | 3 +++
4 files changed, 12 insertions(+)
diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c b/drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c
index 80f4b7785c6c..091e48c217ed 100644
--- a/drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c
+++ b/drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c
@@ -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;
}
diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c b/drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c
index 75aedbb733be..8a49ba6e44f9 100644
--- a/drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c
+++ b/drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c
@@ -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;
}
diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c b/drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c
index 3abcd95477c0..834b3e82ad9f 100644
--- a/drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c
+++ b/drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c
@@ -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;
}
diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.c b/drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.c
index ac75dce88a4c..552537852459 100644
--- a/drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.c
+++ b/drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.c
@@ -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;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 4/7] platform/x86: dell-wmi-sysman: Fix release_attributes_data() getting called twice on init_bios_attributes() failure
2021-03-21 11:58 [PATCH v2 0/7] platform/x86: dell-wmi-sysman: Various error-handling and robustness fixes Hans de Goede
` (2 preceding siblings ...)
2021-03-21 11:58 ` [PATCH v2 3/7] platform/x86: dell-wmi-sysman: Make it safe to call exit_foo_attributes() multiple times Hans de Goede
@ 2021-03-21 11:58 ` Hans de Goede
2021-03-21 11:58 ` [PATCH v2 5/7] platform/x86: dell-wmi-sysman: Cleanup sysman_init() error-exit handling Hans de Goede
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Hans de Goede @ 2021-03-21 11:58 UTC (permalink / raw)
To: Mark Gross, Andy Shevchenko
Cc: Hans de Goede, Mario Limonciello, Divya Bharathi,
Alexander Naumann, platform-driver-x86
All calls of init_bios_attributes() will result in a
goto fail_create_group if they fail, which calls
release_attributes_data().
So there is no need to call release_attributes_data() from
init_bios_attributes() on failure itself.
Fixes: e8a60aa7404b ("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>
---
drivers/platform/x86/dell/dell-wmi-sysman/sysman.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
index 8b251b2c37a2..58dc4571f987 100644
--- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
+++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
@@ -491,7 +491,6 @@ static int init_bios_attributes(int attr_type, const char *guid)
err_attr_init:
mutex_unlock(&wmi_priv.mutex);
- release_attributes_data();
kfree(obj);
return retval;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 5/7] platform/x86: dell-wmi-sysman: Cleanup sysman_init() error-exit handling
2021-03-21 11:58 [PATCH v2 0/7] platform/x86: dell-wmi-sysman: Various error-handling and robustness fixes Hans de Goede
` (3 preceding siblings ...)
2021-03-21 11:58 ` [PATCH v2 4/7] platform/x86: dell-wmi-sysman: Fix release_attributes_data() getting called twice on init_bios_attributes() failure Hans de Goede
@ 2021-03-21 11:58 ` Hans de Goede
2021-03-21 11:59 ` [PATCH v2 6/7] platform/x86: dell-wmi-sysman: Make sysman_init() return -ENODEV of the interfaces are not found Hans de Goede
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Hans de Goede @ 2021-03-21 11:58 UTC (permalink / raw)
To: Mark Gross, Andy Shevchenko
Cc: Hans de Goede, Mario Limonciello, Divya Bharathi,
Alexander Naumann, platform-driver-x86
Cleanup sysman_init() error-exit handling:
1. There is no need for the fail_reset_bios and fail_authentication_kset
eror-exit cases, these can be handled by release_attributes_data()
2. Rename all the labels from fail_what_failed, to err_what_to_cleanup
this is the usual way to name these and avoids the need to rename
them when extra steps are added.
Fixes: e8a60aa7404b ("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>
---
.../x86/dell/dell-wmi-sysman/sysman.c | 45 +++++++------------
1 file changed, 16 insertions(+), 29 deletions(-)
diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
index 58dc4571f987..99dc2f3bdf49 100644
--- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
+++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
@@ -508,100 +508,87 @@ static int __init sysman_init(void)
ret = init_bios_attr_set_interface();
if (ret || !wmi_priv.bios_attr_wdev) {
pr_debug("failed to initialize set interface\n");
- goto fail_set_interface;
+ return ret;
}
ret = init_bios_attr_pass_interface();
if (ret || !wmi_priv.password_attr_wdev) {
pr_debug("failed to initialize pass interface\n");
- goto fail_pass_interface;
+ goto err_exit_bios_attr_set_interface;
}
ret = class_register(&firmware_attributes_class);
if (ret)
- goto fail_class;
+ goto err_exit_bios_attr_pass_interface;
wmi_priv.class_dev = device_create(&firmware_attributes_class, NULL, MKDEV(0, 0),
NULL, "%s", DRIVER_NAME);
if (IS_ERR(wmi_priv.class_dev)) {
ret = PTR_ERR(wmi_priv.class_dev);
- goto fail_classdev;
+ goto err_unregister_class;
}
wmi_priv.main_dir_kset = kset_create_and_add("attributes", NULL,
&wmi_priv.class_dev->kobj);
if (!wmi_priv.main_dir_kset) {
ret = -ENOMEM;
- goto fail_main_kset;
+ goto err_destroy_classdev;
}
wmi_priv.authentication_dir_kset = kset_create_and_add("authentication", NULL,
&wmi_priv.class_dev->kobj);
if (!wmi_priv.authentication_dir_kset) {
ret = -ENOMEM;
- goto fail_authentication_kset;
+ goto err_release_attributes_data;
}
ret = create_attributes_level_sysfs_files();
if (ret) {
pr_debug("could not create reset BIOS attribute\n");
- goto fail_reset_bios;
+ goto err_release_attributes_data;
}
ret = init_bios_attributes(ENUM, DELL_WMI_BIOS_ENUMERATION_ATTRIBUTE_GUID);
if (ret) {
pr_debug("failed to populate enumeration type attributes\n");
- goto fail_create_group;
+ goto err_release_attributes_data;
}
ret = init_bios_attributes(INT, DELL_WMI_BIOS_INTEGER_ATTRIBUTE_GUID);
if (ret) {
pr_debug("failed to populate integer type attributes\n");
- goto fail_create_group;
+ goto err_release_attributes_data;
}
ret = init_bios_attributes(STR, DELL_WMI_BIOS_STRING_ATTRIBUTE_GUID);
if (ret) {
pr_debug("failed to populate string type attributes\n");
- goto fail_create_group;
+ goto err_release_attributes_data;
}
ret = init_bios_attributes(PO, DELL_WMI_BIOS_PASSOBJ_ATTRIBUTE_GUID);
if (ret) {
pr_debug("failed to populate pass object type attributes\n");
- goto fail_create_group;
+ goto err_release_attributes_data;
}
return 0;
-fail_create_group:
+err_release_attributes_data:
release_attributes_data();
-fail_reset_bios:
- if (wmi_priv.authentication_dir_kset) {
- kset_unregister(wmi_priv.authentication_dir_kset);
- wmi_priv.authentication_dir_kset = NULL;
- }
-
-fail_authentication_kset:
- if (wmi_priv.main_dir_kset) {
- kset_unregister(wmi_priv.main_dir_kset);
- wmi_priv.main_dir_kset = NULL;
- }
-
-fail_main_kset:
+err_destroy_classdev:
device_destroy(&firmware_attributes_class, MKDEV(0, 0));
-fail_classdev:
+err_unregister_class:
class_unregister(&firmware_attributes_class);
-fail_class:
+err_exit_bios_attr_pass_interface:
exit_bios_attr_pass_interface();
-fail_pass_interface:
+err_exit_bios_attr_set_interface:
exit_bios_attr_set_interface();
-fail_set_interface:
return ret;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 6/7] platform/x86: dell-wmi-sysman: Make sysman_init() return -ENODEV of the interfaces are not found
2021-03-21 11:58 [PATCH v2 0/7] platform/x86: dell-wmi-sysman: Various error-handling and robustness fixes Hans de Goede
` (4 preceding siblings ...)
2021-03-21 11:58 ` [PATCH v2 5/7] platform/x86: dell-wmi-sysman: Cleanup sysman_init() error-exit handling Hans de Goede
@ 2021-03-21 11:59 ` Hans de Goede
2021-03-21 11:59 ` [PATCH v2 7/7] platform/x86: dell-wmi-sysman: Cleanup create_attributes_level_sysfs_files() Hans de Goede
2021-03-21 16:41 ` [PATCH v2 0/7] platform/x86: dell-wmi-sysman: Various error-handling and robustness fixes Hans de Goede
7 siblings, 0 replies; 9+ messages in thread
From: Hans de Goede @ 2021-03-21 11:59 UTC (permalink / raw)
To: Mark Gross, Andy Shevchenko
Cc: Hans de Goede, Mario Limonciello, Divya Bharathi,
Alexander Naumann, platform-driver-x86
When either the attributes or the password interface is not found, then
unregister the 2 wmi drivers again and return -ENODEV from sysman_init().
Fixes: e8a60aa7404b ("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>
Reported-by: Alexander Naumann <alexandernaumann@gmx.de>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/platform/x86/dell/dell-wmi-sysman/sysman.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
index 99dc2f3bdf49..5dd9b29d939c 100644
--- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
+++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
@@ -506,15 +506,17 @@ static int __init sysman_init(void)
}
ret = init_bios_attr_set_interface();
- if (ret || !wmi_priv.bios_attr_wdev) {
- pr_debug("failed to initialize set interface\n");
+ if (ret)
return ret;
- }
ret = init_bios_attr_pass_interface();
- if (ret || !wmi_priv.password_attr_wdev) {
- pr_debug("failed to initialize pass interface\n");
+ if (ret)
goto err_exit_bios_attr_set_interface;
+
+ if (!wmi_priv.bios_attr_wdev || !wmi_priv.password_attr_wdev) {
+ pr_debug("failed to find set or pass interface\n");
+ ret = -ENODEV;
+ goto err_exit_bios_attr_pass_interface;
}
ret = class_register(&firmware_attributes_class);
--
2.30.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 7/7] platform/x86: dell-wmi-sysman: Cleanup create_attributes_level_sysfs_files()
2021-03-21 11:58 [PATCH v2 0/7] platform/x86: dell-wmi-sysman: Various error-handling and robustness fixes Hans de Goede
` (5 preceding siblings ...)
2021-03-21 11:59 ` [PATCH v2 6/7] platform/x86: dell-wmi-sysman: Make sysman_init() return -ENODEV of the interfaces are not found Hans de Goede
@ 2021-03-21 11:59 ` Hans de Goede
2021-03-21 16:41 ` [PATCH v2 0/7] platform/x86: dell-wmi-sysman: Various error-handling and robustness fixes Hans de Goede
7 siblings, 0 replies; 9+ messages in thread
From: Hans de Goede @ 2021-03-21 11:59 UTC (permalink / raw)
To: Mark Gross, Andy Shevchenko
Cc: Hans de Goede, Mario Limonciello, Divya Bharathi,
Alexander Naumann, platform-driver-x86
Cleanup create_attributes_level_sysfs_files():
1. There is no need to call sysfs_remove_file() on error, sysman_init()
will already call release_attributes_data() on failure which already does
this.
2. There is no need for the pr_debug() calls sysfs_create_file() should
never fail and if it does it will already complain about the problem
itself.
Fixes: e8a60aa7404b ("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>
---
.../platform/x86/dell/dell-wmi-sysman/sysman.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
index 5dd9b29d939c..7410ccae650c 100644
--- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
+++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
@@ -210,19 +210,17 @@ static struct kobj_attribute pending_reboot = __ATTR_RO(pending_reboot);
*/
static int create_attributes_level_sysfs_files(void)
{
- int ret = sysfs_create_file(&wmi_priv.main_dir_kset->kobj, &reset_bios.attr);
+ int ret;
- if (ret) {
- pr_debug("could not create reset_bios file\n");
+ ret = sysfs_create_file(&wmi_priv.main_dir_kset->kobj, &reset_bios.attr);
+ if (ret)
return ret;
- }
ret = sysfs_create_file(&wmi_priv.main_dir_kset->kobj, &pending_reboot.attr);
- if (ret) {
- pr_debug("could not create changing_pending_reboot file\n");
- sysfs_remove_file(&wmi_priv.main_dir_kset->kobj, &reset_bios.attr);
- }
- return ret;
+ if (ret)
+ return ret;
+
+ return 0;
}
static ssize_t wmi_sysman_attr_show(struct kobject *kobj, struct attribute *attr,
--
2.30.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/7] platform/x86: dell-wmi-sysman: Various error-handling and robustness fixes
2021-03-21 11:58 [PATCH v2 0/7] platform/x86: dell-wmi-sysman: Various error-handling and robustness fixes Hans de Goede
` (6 preceding siblings ...)
2021-03-21 11:59 ` [PATCH v2 7/7] platform/x86: dell-wmi-sysman: Cleanup create_attributes_level_sysfs_files() Hans de Goede
@ 2021-03-21 16:41 ` Hans de Goede
7 siblings, 0 replies; 9+ messages in thread
From: Hans de Goede @ 2021-03-21 16:41 UTC (permalink / raw)
To: Mark Gross, Andy Shevchenko
Cc: Mario Limonciello, Divya Bharathi, Alexander Naumann,
platform-driver-x86
Hi,
On 3/21/21 12:58 PM, Hans de Goede wrote:
> Hi All,
>
> There have been several bug-reports about crashes related to the
> dell-wmi-sysman module:
>
> https://bugzilla.redhat.com/show_bug.cgi?id=1936171
> https://bugzilla.kernel.org/show_bug.cgi?id=211895
> https://bugs.archlinux.org/task/69702
>
> Here is v2 of my series with a bunch of fixes for NULL pointer derefs,
> double-frees, etc. which fixes this.
>
> New in v2:
> -New patch: "platform/x86: dell-wmi-sysman: Fix crash caused by calling
> kset_unregister twice" which addresses the direct-cause of
> the crash. Note that the crash was already fixed in v1 because
> that removed the code-path where kset_unregister ended up being
> called twice.
>
> -Dropped: "platform/x86: dell-wmi-sysman: Make init_bios_attributes()
> ACPI object parsing more robust". This needs more testing / discussion
> and is not necessary to fix the boot-failure which people are seeing.
I've added this series to the pdx86/review-hans and pdx86/fixes branches,
so it should show up in linux-next soon and it will also be included
in my next pull-req to Linus for 5.12.
Regards,
Hans
> Hans de Goede (7):
> platform/x86: dell-wmi-sysman: Fix crash caused by calling
> kset_unregister twice
> platform/x86: dell-wmi-sysman: Fix possible NULL pointer deref on exit
> platform/x86: dell-wmi-sysman: Make it safe to call
> exit_foo_attributes() multiple times
> platform/x86: dell-wmi-sysman: Fix release_attributes_data() getting
> called twice on init_bios_attributes() failure
> platform/x86: dell-wmi-sysman: Cleanup sysman_init() error-exit
> handling
> platform/x86: dell-wmi-sysman: Make sysman_init() return -ENODEV of
> the interfaces are not found
> platform/x86: dell-wmi-sysman: Cleanup
> create_attributes_level_sysfs_files()
>
> .../dell/dell-wmi-sysman/enum-attributes.c | 3 +
> .../x86/dell/dell-wmi-sysman/int-attributes.c | 3 +
> .../dell/dell-wmi-sysman/passobj-attributes.c | 3 +
> .../dell/dell-wmi-sysman/string-attributes.c | 3 +
> .../x86/dell/dell-wmi-sysman/sysman.c | 84 +++++++------------
> 5 files changed, 44 insertions(+), 52 deletions(-)
>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-03-21 16:42 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-21 11:58 [PATCH v2 0/7] platform/x86: dell-wmi-sysman: Various error-handling and robustness fixes Hans de Goede
2021-03-21 11:58 ` [PATCH v2 1/7] platform/x86: dell-wmi-sysman: Fix crash caused by calling kset_unregister twice Hans de Goede
2021-03-21 11:58 ` [PATCH v2 2/7] platform/x86: dell-wmi-sysman: Fix possible NULL pointer deref on exit Hans de Goede
2021-03-21 11:58 ` [PATCH v2 3/7] platform/x86: dell-wmi-sysman: Make it safe to call exit_foo_attributes() multiple times Hans de Goede
2021-03-21 11:58 ` [PATCH v2 4/7] platform/x86: dell-wmi-sysman: Fix release_attributes_data() getting called twice on init_bios_attributes() failure Hans de Goede
2021-03-21 11:58 ` [PATCH v2 5/7] platform/x86: dell-wmi-sysman: Cleanup sysman_init() error-exit handling Hans de Goede
2021-03-21 11:59 ` [PATCH v2 6/7] platform/x86: dell-wmi-sysman: Make sysman_init() return -ENODEV of the interfaces are not found Hans de Goede
2021-03-21 11:59 ` [PATCH v2 7/7] platform/x86: dell-wmi-sysman: Cleanup create_attributes_level_sysfs_files() Hans de Goede
2021-03-21 16:41 ` [PATCH v2 0/7] platform/x86: dell-wmi-sysman: Various error-handling and robustness fixes Hans de Goede
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).