Skip to content

Commit b11397b

Browse files
kuu-rtgregkh
authored andcommitted
platform/x86: think-lmi: Create ksets consecutively
commit 8dab34c upstream. 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 <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Cc: [email protected] Signed-off-by: Kurt Borja <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ilpo Järvinen <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f5fe094 commit b11397b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/platform/x86/think-lmi.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,6 +1388,14 @@ static int tlmi_sysfs_init(void)
13881388
goto fail_device_created;
13891389
}
13901390

1391+
tlmi_priv.authentication_kset = kset_create_and_add("authentication", NULL,
1392+
&tlmi_priv.class_dev->kobj);
1393+
if (!tlmi_priv.authentication_kset) {
1394+
kset_unregister(tlmi_priv.attribute_kset);
1395+
ret = -ENOMEM;
1396+
goto fail_device_created;
1397+
}
1398+
13911399
for (i = 0; i < TLMI_SETTINGS_COUNT; i++) {
13921400
/* Check if index is a valid setting - skip if it isn't */
13931401
if (!tlmi_priv.setting[i])
@@ -1429,12 +1437,6 @@ static int tlmi_sysfs_init(void)
14291437
}
14301438

14311439
/* Create authentication entries */
1432-
tlmi_priv.authentication_kset = kset_create_and_add("authentication", NULL,
1433-
&tlmi_priv.class_dev->kobj);
1434-
if (!tlmi_priv.authentication_kset) {
1435-
ret = -ENOMEM;
1436-
goto fail_create_attr;
1437-
}
14381440
tlmi_priv.pwd_admin->kobj.kset = tlmi_priv.authentication_kset;
14391441
ret = kobject_add(&tlmi_priv.pwd_admin->kobj, NULL, "%s", "Admin");
14401442
if (ret)

0 commit comments

Comments
 (0)