]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
platform/x86: think-lmi: Create ksets consecutively
authorKurt Borja <kuurtb@gmail.com>
Mon, 30 Jun 2025 17:31:19 +0000 (14:31 -0300)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Wed, 2 Jul 2025 09:01:21 +0000 (12:01 +0300)
Avoid entering tlmi_release_attr() in error paths if both ksets are not
yet created.

This is accomplished by initializing them side by side.

Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
Link: https://lore.kernel.org/r/20250630-lmi-fix-v3-1-ce4f81c9c481@gmail.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/think-lmi.c

index 28ce475f6c3776f7f83ce4b78d6c6437b3663fd9..39306951f234bd7741bf6e8daadc8d22664abe68 100644 (file)
@@ -1455,6 +1455,14 @@ static int tlmi_sysfs_init(void)
                goto fail_device_created;
        }
 
+       tlmi_priv.authentication_kset = kset_create_and_add("authentication", NULL,
+                                                           &tlmi_priv.class_dev->kobj);
+       if (!tlmi_priv.authentication_kset) {
+               kset_unregister(tlmi_priv.attribute_kset);
+               ret = -ENOMEM;
+               goto fail_device_created;
+       }
+
        for (i = 0; i < TLMI_SETTINGS_COUNT; i++) {
                /* Check if index is a valid setting - skip if it isn't */
                if (!tlmi_priv.setting[i])
@@ -1496,12 +1504,6 @@ static int tlmi_sysfs_init(void)
        }
 
        /* Create authentication entries */
-       tlmi_priv.authentication_kset = kset_create_and_add("authentication", NULL,
-                                                               &tlmi_priv.class_dev->kobj);
-       if (!tlmi_priv.authentication_kset) {
-               ret = -ENOMEM;
-               goto fail_create_attr;
-       }
        tlmi_priv.pwd_admin->kobj.kset = tlmi_priv.authentication_kset;
        ret = kobject_add(&tlmi_priv.pwd_admin->kobj, NULL, "%s", "Admin");
        if (ret)