Skip to content

Commit 545896e

Browse files
jwrdegoedeSeth Forshee
authored andcommitted
platform/x86: dell-wmi-sysman: Cleanup sysman_init() error-exit handling
BugLink: https://bugs.launchpad.net/bugs/1922601 [ Upstream commit 9c90cd8 ] Cleanup sysman_init() error-exit handling: 1. There is no need for the fail_reset_bios and fail_authentication_kset eror-exit cases, these can be handled by release_attributes_data() 2. Rename all the labels from fail_what_failed, to err_what_to_cleanup this is the usual way to name these and avoids the need to rename them when extra steps are added. Fixes: e8a60aa ("platform/x86: Introduce support for Systems Management Driver over WMI for Dell Systems") Cc: Divya Bharathi <Divya_Bharathi@dell.com> Cc: Mario Limonciello <mario.limonciello@dell.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20210321115901.35072-6-hdegoede@redhat.com Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
1 parent c8a9b2b commit 545896e

File tree

1 file changed

+16
-29
lines changed
  • drivers/platform/x86/dell-wmi-sysman

1 file changed

+16
-29
lines changed

drivers/platform/x86/dell-wmi-sysman/sysman.c

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -508,100 +508,87 @@ static int __init sysman_init(void)
508508
ret = init_bios_attr_set_interface();
509509
if (ret || !wmi_priv.bios_attr_wdev) {
510510
pr_debug("failed to initialize set interface\n");
511-
goto fail_set_interface;
511+
return ret;
512512
}
513513

514514
ret = init_bios_attr_pass_interface();
515515
if (ret || !wmi_priv.password_attr_wdev) {
516516
pr_debug("failed to initialize pass interface\n");
517-
goto fail_pass_interface;
517+
goto err_exit_bios_attr_set_interface;
518518
}
519519

520520
ret = class_register(&firmware_attributes_class);
521521
if (ret)
522-
goto fail_class;
522+
goto err_exit_bios_attr_pass_interface;
523523

524524
wmi_priv.class_dev = device_create(&firmware_attributes_class, NULL, MKDEV(0, 0),
525525
NULL, "%s", DRIVER_NAME);
526526
if (IS_ERR(wmi_priv.class_dev)) {
527527
ret = PTR_ERR(wmi_priv.class_dev);
528-
goto fail_classdev;
528+
goto err_unregister_class;
529529
}
530530

531531
wmi_priv.main_dir_kset = kset_create_and_add("attributes", NULL,
532532
&wmi_priv.class_dev->kobj);
533533
if (!wmi_priv.main_dir_kset) {
534534
ret = -ENOMEM;
535-
goto fail_main_kset;
535+
goto err_destroy_classdev;
536536
}
537537

538538
wmi_priv.authentication_dir_kset = kset_create_and_add("authentication", NULL,
539539
&wmi_priv.class_dev->kobj);
540540
if (!wmi_priv.authentication_dir_kset) {
541541
ret = -ENOMEM;
542-
goto fail_authentication_kset;
542+
goto err_release_attributes_data;
543543
}
544544

545545
ret = create_attributes_level_sysfs_files();
546546
if (ret) {
547547
pr_debug("could not create reset BIOS attribute\n");
548-
goto fail_reset_bios;
548+
goto err_release_attributes_data;
549549
}
550550

551551
ret = init_bios_attributes(ENUM, DELL_WMI_BIOS_ENUMERATION_ATTRIBUTE_GUID);
552552
if (ret) {
553553
pr_debug("failed to populate enumeration type attributes\n");
554-
goto fail_create_group;
554+
goto err_release_attributes_data;
555555
}
556556

557557
ret = init_bios_attributes(INT, DELL_WMI_BIOS_INTEGER_ATTRIBUTE_GUID);
558558
if (ret) {
559559
pr_debug("failed to populate integer type attributes\n");
560-
goto fail_create_group;
560+
goto err_release_attributes_data;
561561
}
562562

563563
ret = init_bios_attributes(STR, DELL_WMI_BIOS_STRING_ATTRIBUTE_GUID);
564564
if (ret) {
565565
pr_debug("failed to populate string type attributes\n");
566-
goto fail_create_group;
566+
goto err_release_attributes_data;
567567
}
568568

569569
ret = init_bios_attributes(PO, DELL_WMI_BIOS_PASSOBJ_ATTRIBUTE_GUID);
570570
if (ret) {
571571
pr_debug("failed to populate pass object type attributes\n");
572-
goto fail_create_group;
572+
goto err_release_attributes_data;
573573
}
574574

575575
return 0;
576576

577-
fail_create_group:
577+
err_release_attributes_data:
578578
release_attributes_data();
579579

580-
fail_reset_bios:
581-
if (wmi_priv.authentication_dir_kset) {
582-
kset_unregister(wmi_priv.authentication_dir_kset);
583-
wmi_priv.authentication_dir_kset = NULL;
584-
}
585-
586-
fail_authentication_kset:
587-
if (wmi_priv.main_dir_kset) {
588-
kset_unregister(wmi_priv.main_dir_kset);
589-
wmi_priv.main_dir_kset = NULL;
590-
}
591-
592-
fail_main_kset:
580+
err_destroy_classdev:
593581
device_destroy(&firmware_attributes_class, MKDEV(0, 0));
594582

595-
fail_classdev:
583+
err_unregister_class:
596584
class_unregister(&firmware_attributes_class);
597585

598-
fail_class:
586+
err_exit_bios_attr_pass_interface:
599587
exit_bios_attr_pass_interface();
600588

601-
fail_pass_interface:
589+
err_exit_bios_attr_set_interface:
602590
exit_bios_attr_set_interface();
603591

604-
fail_set_interface:
605592
return ret;
606593
}
607594

0 commit comments

Comments
 (0)