Commit 20f67902 authored by Dan Carpenter's avatar Dan Carpenter Committed by Hans de Goede

platform/x86: dell-wmi-sysman: fix init_bios_attributes() error handling

Calling release_attributes_data() while holding the "wmi_priv.mutex"
will lead to a dead lock.  The other problem is that if kzalloc() fails
then this should return -ENOMEM but currently it returns success.

Fixes: e8a60aa7 ("platform/x86: Introduce support for Systems Management Driver over WMI for Dell Systems")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20201103101735.GB1127762@mwandaSigned-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent 274335f1
...@@ -443,8 +443,10 @@ static int init_bios_attributes(int attr_type, const char *guid) ...@@ -443,8 +443,10 @@ static int init_bios_attributes(int attr_type, const char *guid)
/* build attribute */ /* build attribute */
attr_name_kobj = kzalloc(sizeof(*attr_name_kobj), GFP_KERNEL); attr_name_kobj = kzalloc(sizeof(*attr_name_kobj), GFP_KERNEL);
if (!attr_name_kobj) if (!attr_name_kobj) {
retval = -ENOMEM;
goto err_attr_init; goto err_attr_init;
}
attr_name_kobj->kset = tmp_set; attr_name_kobj->kset = tmp_set;
...@@ -486,13 +488,13 @@ static int init_bios_attributes(int attr_type, const char *guid) ...@@ -486,13 +488,13 @@ static int init_bios_attributes(int attr_type, const char *guid)
elements = obj ? obj->package.elements : NULL; elements = obj ? obj->package.elements : NULL;
} }
goto out; mutex_unlock(&wmi_priv.mutex);
return 0;
err_attr_init: err_attr_init:
mutex_unlock(&wmi_priv.mutex);
release_attributes_data(); release_attributes_data();
kfree(obj); kfree(obj);
out:
mutex_unlock(&wmi_priv.mutex);
return retval; return retval;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment