Commit 1b259904 authored by Markus Elfring's avatar Markus Elfring Committed by Marcel Holtmann

Bluetooth: Use common error handling code in bt_init()

* Improve jump targets so that a bit of exception handling can be better
  reused at the end of this function.

* Adjust five condition checks.

This issue was detected by using the Coccinelle software.
Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent ba8f3597
...@@ -766,43 +766,39 @@ static int __init bt_init(void) ...@@ -766,43 +766,39 @@ static int __init bt_init(void)
return err; return err;
err = sock_register(&bt_sock_family_ops); err = sock_register(&bt_sock_family_ops);
if (err < 0) { if (err)
bt_sysfs_cleanup(); goto cleanup_sysfs;
return err;
}
BT_INFO("HCI device and connection manager initialized"); BT_INFO("HCI device and connection manager initialized");
err = hci_sock_init(); err = hci_sock_init();
if (err < 0) if (err)
goto error; goto unregister_socket;
err = l2cap_init(); err = l2cap_init();
if (err < 0) if (err)
goto sock_err; goto cleanup_socket;
err = sco_init(); err = sco_init();
if (err < 0) { if (err)
l2cap_exit(); goto cleanup_cap;
goto sock_err;
}
err = mgmt_init(); err = mgmt_init();
if (err < 0) { if (err)
sco_exit(); goto cleanup_sco;
l2cap_exit();
goto sock_err;
}
return 0; return 0;
sock_err: cleanup_sco:
sco_exit();
cleanup_cap:
l2cap_exit();
cleanup_socket:
hci_sock_cleanup(); hci_sock_cleanup();
unregister_socket:
error:
sock_unregister(PF_BLUETOOTH); sock_unregister(PF_BLUETOOTH);
cleanup_sysfs:
bt_sysfs_cleanup(); bt_sysfs_cleanup();
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment