Commit 7295a996 authored by Armin Wolf's avatar Armin Wolf Committed by Hans de Goede

platform/x86: dell-sysman: Fix reference leak

If a duplicate attribute is found using kset_find_obj(),
a reference to that attribute is returned. This means
that we need to dispose it accordingly. Use kobject_put()
to dispose the duplicate attribute in such a case.

Compile-tested only.

Fixes: e8a60aa7 ("platform/x86: Introduce support for Systems Management Driver over WMI for Dell Systems")
Signed-off-by: default avatarArmin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20230805053610.7106-1-W_Armin@gmx.deReviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent 6f8972a0
...@@ -393,6 +393,7 @@ static int init_bios_attributes(int attr_type, const char *guid) ...@@ -393,6 +393,7 @@ static int init_bios_attributes(int attr_type, const char *guid)
struct kobject *attr_name_kobj; //individual attribute names struct kobject *attr_name_kobj; //individual attribute names
union acpi_object *obj = NULL; union acpi_object *obj = NULL;
union acpi_object *elements; union acpi_object *elements;
struct kobject *duplicate;
struct kset *tmp_set; struct kset *tmp_set;
int min_elements; int min_elements;
...@@ -451,9 +452,11 @@ static int init_bios_attributes(int attr_type, const char *guid) ...@@ -451,9 +452,11 @@ static int init_bios_attributes(int attr_type, const char *guid)
else else
tmp_set = wmi_priv.main_dir_kset; tmp_set = wmi_priv.main_dir_kset;
if (kset_find_obj(tmp_set, elements[ATTR_NAME].string.pointer)) { duplicate = kset_find_obj(tmp_set, elements[ATTR_NAME].string.pointer);
pr_debug("duplicate attribute name found - %s\n", if (duplicate) {
elements[ATTR_NAME].string.pointer); pr_debug("Duplicate attribute name found - %s\n",
elements[ATTR_NAME].string.pointer);
kobject_put(duplicate);
goto nextobj; goto nextobj;
} }
......
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