Skip to content

Commit

Permalink
rfkill: Cleanup error handling in rfkill_init()
Browse files Browse the repository at this point in the history
Use a separate label per error condition in rfkill_init() to make it a
bit cleaner and easier to extend.

Signed-off-by: Michał Kępień <[email protected]>
Signed-off-by: Johannes Berg <[email protected]>
  • Loading branch information
kempniu authored and jmberg-intel committed Dec 13, 2016
1 parent 4a5ecca commit 6124c53
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions net/rfkill/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1263,24 +1263,25 @@ static int __init rfkill_init(void)

error = class_register(&rfkill_class);
if (error)
goto out;
goto error_class;

error = misc_register(&rfkill_miscdev);
if (error) {
class_unregister(&rfkill_class);
goto out;
}
if (error)
goto error_misc;

#ifdef CONFIG_RFKILL_INPUT
error = rfkill_handler_init();
if (error) {
misc_deregister(&rfkill_miscdev);
class_unregister(&rfkill_class);
goto out;
}
if (error)
goto error_input;
#endif

out:
return 0;

error_input:
misc_deregister(&rfkill_miscdev);
error_misc:
class_unregister(&rfkill_class);
error_class:
return error;
}
subsys_initcall(rfkill_init);
Expand Down

0 comments on commit 6124c53

Please sign in to comment.