NET/bluetooth: handle sysfs errors
Subsystems (3)
PATCH 1/1 NET/bluetooth: handle sysfs errors
Signed-off-by Jeff Garzik <[email protected]>
---
net/bluetooth/l2cap.c | 19 ++++++++++++++----- net/bluetooth/rfcomm/core.c | 21 ++++++++++++++++++--- net/bluetooth/rfcomm/sock.c | 7 ++++++- net/bluetooth/sco.c | 17 ++++++++++++----- 4 files changed, 50 insertions(+), 14 deletions(-)
net/bluetooth/l2cap.c +14 -5
@@ -2206,24 +2206,33 @@ static int __init l2cap_init(void) err =bt_sock_register (BTPROTO_L2CAP , &l2cap_sock_family_ops);if (err <0 ) {BT_ERR ("L2CAP socket registration failed" ); - goto error; + goto err_proto; } err =hci_register_proto (&l2cap_hci_proto);if (err <0 ) {BT_ERR ("L2CAP protocol registration failed" ); -bt_sock_unregister (BTPROTO_L2CAP ); - goto error; + goto err_sock; } -class_create_file (bt_class, &class_attr_l2cap); + err =class_create_file (bt_class, &class_attr_l2cap); +if (err) { +BT_ERR ("L2CAP class registration failed" ); + goto err_proto2; + }BT_INFO ("L2CAP ver %s" ,VERSION );BT_INFO ("L2CAP socket layer initialized" );return 0 ; -error: +err_proto2: +if (hci_unregister_proto (&l2cap_hci_proto) <0 ) +BT_ERR ("L2CAP protocol unregistration failed" ); +err_sock: +if (bt_sock_unregister (BTPROTO_L2CAP ) <0 ) +BT_ERR ("L2CAP socket unregistration failed" ); +err_proto:proto_unregister (&l2cap_proto);return err; }
net/bluetooth/rfcomm/core.c +18 -3
@@ -2052,13 +2052,21 @@ static CLASS_ATTR(rfcomm_dlc, S_IRUGO, r/* ---- Initialization ---- */ static int __init rfcomm_init (void ) { +int rc; +l2cap_load (); -hci_register_cb (&rfcomm_cb); + rc =hci_register_cb (&rfcomm_cb); +if (rc) + goto err; -kernel_thread (rfcomm_run,NULL ,CLONE_KERNEL ); + rc =class_create_file (bt_class, &class_attr_rfcomm_dlc); +if (rc) + goto err_hcireg; -class_create_file (bt_class, &class_attr_rfcomm_dlc); + rc =kernel_thread (rfcomm_run,NULL ,CLONE_KERNEL ); +if (rc <0 ) + goto err_file;rfcomm_init_sockets ();
@@ -2069,6 +2077,13 @@ #endifBT_INFO ("RFCOMM ver %s" ,VERSION );return 0 ; + +err_file: +class_remove_file (bt_class, &class_attr_rfcomm_dlc); +err_hcireg: +hci_unregister_cb (&rfcomm_cb); +err: +return rc; } static void __exit rfcomm_exit(void)
net/bluetooth/rfcomm/sock.c +6 -1
@@ -944,12 +944,17 @@ int __init rfcomm_init_sockets(void)if (err <0 ) goto error; -class_create_file (bt_class, &class_attr_rfcomm); + err =class_create_file (bt_class, &class_attr_rfcomm); +if (err) + goto error_sock;BT_INFO ("RFCOMM socket layer initialized" );return 0 ; +error_sock: +if (bt_sock_unregister (BTPROTO_RFCOMM ) <0 ) +BT_ERR ("RFCOMM socket layer unregistration failed" ); error:BT_ERR ("RFCOMM socket layer registration failed" );proto_unregister (&rfcomm_proto);
net/bluetooth/sco.c +12 -5
@@ -957,24 +957,31 @@ static int __init sco_init(void) err =bt_sock_register (BTPROTO_SCO , &sco_sock_family_ops);if (err <0 ) {BT_ERR ("SCO socket registration failed" ); - goto error; + goto err_proto; } err =hci_register_proto (&sco_hci_proto);if (err <0 ) {BT_ERR ("SCO protocol registration failed" ); -bt_sock_unregister (BTPROTO_SCO ); - goto error; + goto err_sock; } -class_create_file (bt_class, &class_attr_sco); + err =class_create_file (bt_class, &class_attr_sco); +if (err) + goto err_proto2;BT_INFO ("SCO (Voice Link) ver %s" ,VERSION );BT_INFO ("SCO socket layer initialized" );return 0 ; -error: +err_proto2: +if (hci_unregister_proto (&sco_hci_proto) <0 ) +BT_ERR ("SCO protocol unregistration failed" ); +err_sock: +if (bt_sock_unregister (BTPROTO_SCO ) <0 ) +BT_ERR ("SCO socket unregistration failed" ); +err_proto:proto_unregister (&sco_proto);return err; }
Marcel Holtmann
maintainerHi Jeff,
thanks for the patch, but I already have one that fixes this and it will go to David Miller for inclusion soon.
Regards
Marcel