diff options
author | 2020-11-03 13:17:35 +0300 | |
---|---|---|
committer | 2020-11-09 12:54:24 +0100 | |
commit | 20f67902824f04bc9a319814d5872c8ff6a74559 (patch) | |
tree | 2cf8e5cf72b678ac3447b79361af98b8fd605f60 /drivers/platform | |
parent | platform/surface: Add Driver to set up lid GPEs on MS Surface device (diff) | |
download | linux-20f67902824f04bc9a319814d5872c8ff6a74559.tar.gz linux-20f67902824f04bc9a319814d5872c8ff6a74559.tar.bz2 linux-20f67902824f04bc9a319814d5872c8ff6a74559.zip |
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: e8a60aa7404b ("platform/x86: Introduce support for Systems Management Driver over WMI for Dell Systems")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20201103101735.GB1127762@mwanda
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r-- | drivers/platform/x86/dell-wmi-sysman/sysman.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/platform/x86/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell-wmi-sysman/sysman.c index c6862c3e9b49..dc6dd531c996 100644 --- a/drivers/platform/x86/dell-wmi-sysman/sysman.c +++ b/drivers/platform/x86/dell-wmi-sysman/sysman.c @@ -443,8 +443,10 @@ static int init_bios_attributes(int attr_type, const char *guid) /* build attribute */ attr_name_kobj = kzalloc(sizeof(*attr_name_kobj), GFP_KERNEL); - if (!attr_name_kobj) + if (!attr_name_kobj) { + retval = -ENOMEM; goto err_attr_init; + } attr_name_kobj->kset = tmp_set; @@ -486,13 +488,13 @@ nextobj: elements = obj ? obj->package.elements : NULL; } - goto out; + mutex_unlock(&wmi_priv.mutex); + return 0; err_attr_init: + mutex_unlock(&wmi_priv.mutex); release_attributes_data(); kfree(obj); -out: - mutex_unlock(&wmi_priv.mutex); return retval; } |