Skip to content

Commit 7295a99

Browse files
Wer-Wolfjwrdegoede
authored andcommitted
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: e8a60aa ("platform/x86: Introduce support for Systems Management Driver over WMI for Dell Systems") Signed-off-by: Armin Wolf <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]>
1 parent 6f8972a commit 7295a99

File tree

1 file changed

+6
-3
lines changed
  • drivers/platform/x86/dell/dell-wmi-sysman

1 file changed

+6
-3
lines changed

drivers/platform/x86/dell/dell-wmi-sysman/sysman.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ static int init_bios_attributes(int attr_type, const char *guid)
393393
struct kobject *attr_name_kobj; //individual attribute names
394394
union acpi_object *obj = NULL;
395395
union acpi_object *elements;
396+
struct kobject *duplicate;
396397
struct kset *tmp_set;
397398
int min_elements;
398399

@@ -451,9 +452,11 @@ static int init_bios_attributes(int attr_type, const char *guid)
451452
else
452453
tmp_set = wmi_priv.main_dir_kset;
453454

454-
if (kset_find_obj(tmp_set, elements[ATTR_NAME].string.pointer)) {
455-
pr_debug("duplicate attribute name found - %s\n",
456-
elements[ATTR_NAME].string.pointer);
455+
duplicate = kset_find_obj(tmp_set, elements[ATTR_NAME].string.pointer);
456+
if (duplicate) {
457+
pr_debug("Duplicate attribute name found - %s\n",
458+
elements[ATTR_NAME].string.pointer);
459+
kobject_put(duplicate);
457460
goto nextobj;
458461
}
459462

0 commit comments

Comments
 (0)