Skip to content

Commit 8dab34c

Browse files
kuu-rtij-intel
authored andcommitted
platform/x86: think-lmi: Create ksets consecutively
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]>
1 parent 644bec1 commit 8dab34c

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
@@ -1455,6 +1455,14 @@ static int tlmi_sysfs_init(void)
14551455
goto fail_device_created;
14561456
}
14571457

1458+
tlmi_priv.authentication_kset = kset_create_and_add("authentication", NULL,
1459+
&tlmi_priv.class_dev->kobj);
1460+
if (!tlmi_priv.authentication_kset) {
1461+
kset_unregister(tlmi_priv.attribute_kset);
1462+
ret = -ENOMEM;
1463+
goto fail_device_created;
1464+
}
1465+
14581466
for (i = 0; i < TLMI_SETTINGS_COUNT; i++) {
14591467
/* Check if index is a valid setting - skip if it isn't */
14601468
if (!tlmi_priv.setting[i])
@@ -1496,12 +1504,6 @@ static int tlmi_sysfs_init(void)
14961504
}
14971505

14981506
/* Create authentication entries */
1499-
tlmi_priv.authentication_kset = kset_create_and_add("authentication", NULL,
1500-
&tlmi_priv.class_dev->kobj);
1501-
if (!tlmi_priv.authentication_kset) {
1502-
ret = -ENOMEM;
1503-
goto fail_create_attr;
1504-
}
15051507
tlmi_priv.pwd_admin->kobj.kset = tlmi_priv.authentication_kset;
15061508
ret = kobject_add(&tlmi_priv.pwd_admin->kobj, NULL, "%s", "Admin");
15071509
if (ret)

0 commit comments

Comments
 (0)