Skip to content

Commit dcb76b3

Browse files
kuu-rtgregkh
authored andcommitted
platform/x86: think-lmi: Create ksets consecutively
commit 8dab34ca77293b409c3223636dde915a22656748 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 1426451 commit dcb76b3

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
@@ -1285,6 +1285,14 @@ static int tlmi_sysfs_init(void)
12851285
goto fail_device_created;
12861286
}
12871287

1288+
tlmi_priv.authentication_kset = kset_create_and_add("authentication", NULL,
1289+
&tlmi_priv.class_dev->kobj);
1290+
if (!tlmi_priv.authentication_kset) {
1291+
kset_unregister(tlmi_priv.attribute_kset);
1292+
ret = -ENOMEM;
1293+
goto fail_device_created;
1294+
}
1295+
12881296
for (i = 0; i < TLMI_SETTINGS_COUNT; i++) {
12891297
/* Check if index is a valid setting - skip if it isn't */
12901298
if (!tlmi_priv.setting[i])
@@ -1322,12 +1330,6 @@ static int tlmi_sysfs_init(void)
13221330
}
13231331

13241332
/* Create authentication entries */
1325-
tlmi_priv.authentication_kset = kset_create_and_add("authentication", NULL,
1326-
&tlmi_priv.class_dev->kobj);
1327-
if (!tlmi_priv.authentication_kset) {
1328-
ret = -ENOMEM;
1329-
goto fail_create_attr;
1330-
}
13311333
tlmi_priv.pwd_admin->kobj.kset = tlmi_priv.authentication_kset;
13321334
ret = kobject_add(&tlmi_priv.pwd_admin->kobj, NULL, "%s", "Admin");
13331335
if (ret)

0 commit comments

Comments
 (0)