]> git.hungrycats.org Git - linux/commitdiff
platform/x86: dell-sysman: Fix reference leak
authorArmin Wolf <W_Armin@gmx.de>
Sat, 5 Aug 2023 05:36:10 +0000 (07:36 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Sep 2023 07:48:30 +0000 (09:48 +0200)
[ Upstream commit 7295a996fdab7bf83dc3d4078fa8b139b8e0a1bf ]

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: e8a60aa7404b ("platform/x86: Introduce support for Systems Management Driver over WMI for Dell Systems")
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20230805053610.7106-1-W_Armin@gmx.de
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/platform/x86/dell/dell-wmi-sysman/sysman.c

index 0285b47d99d13d1d4deb49956571d3ed25e5dcda..1dd5aa37ecc8bb036663fa520862a5282e3f1066 100644 (file)
@@ -396,6 +396,7 @@ static int init_bios_attributes(int attr_type, const char *guid)
        struct kobject *attr_name_kobj; //individual attribute names
        union acpi_object *obj = NULL;
        union acpi_object *elements;
+       struct kobject *duplicate;
        struct kset *tmp_set;
        int min_elements;
 
@@ -454,9 +455,11 @@ static int init_bios_attributes(int attr_type, const char *guid)
                else
                        tmp_set = wmi_priv.main_dir_kset;
 
-               if (kset_find_obj(tmp_set, elements[ATTR_NAME].string.pointer)) {
-                       pr_debug("duplicate attribute name found - %s\n",
-                               elements[ATTR_NAME].string.pointer);
+               duplicate = kset_find_obj(tmp_set, elements[ATTR_NAME].string.pointer);
+               if (duplicate) {
+                       pr_debug("Duplicate attribute name found - %s\n",
+                                elements[ATTR_NAME].string.pointer);
+                       kobject_put(duplicate);
                        goto nextobj;
                }