Skip to content

Commit 6124c53

Browse files
kempniujmberg-intel
authored andcommitted
rfkill: Cleanup error handling in rfkill_init()
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ń <kernel@kempniu.pl> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 4a5ecca commit 6124c53

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

‎net/rfkill/core.c‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,24 +1263,25 @@ static int __init rfkill_init(void)
12631263

12641264
error = class_register(&rfkill_class);
12651265
if (error)
1266-
goto out;
1266+
goto error_class;
12671267

12681268
error = misc_register(&rfkill_miscdev);
1269-
if (error) {
1270-
class_unregister(&rfkill_class);
1271-
goto out;
1272-
}
1269+
if (error)
1270+
goto error_misc;
12731271

12741272
#ifdef CONFIG_RFKILL_INPUT
12751273
error = rfkill_handler_init();
1276-
if (error) {
1277-
misc_deregister(&rfkill_miscdev);
1278-
class_unregister(&rfkill_class);
1279-
goto out;
1280-
}
1274+
if (error)
1275+
goto error_input;
12811276
#endif
12821277

1283-
out:
1278+
return 0;
1279+
1280+
error_input:
1281+
misc_deregister(&rfkill_miscdev);
1282+
error_misc:
1283+
class_unregister(&rfkill_class);
1284+
error_class:
12841285
return error;
12851286
}
12861287
subsys_initcall(rfkill_init);

0 commit comments

Comments
 (0)