diff options
author | Anderson Lizardo <anderson.lizardo@openbossa.org> | 2010-11-29 11:15:50 -0500 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2010-12-01 18:04:43 -0500 |
commit | b78d7b4f204a6ba1901af36c95e10fded9816054 (patch) | |
tree | 7c9106a631778aee9ffdeca94e0054a5fe818412 /net/bluetooth/l2cap.c | |
parent | eeb366564be7c311b31c70821d18a43a8a57f9bc (diff) |
Bluetooth: Fix error handling for l2cap_init()
create_singlethread_workqueue() may fail with errors such as -ENOMEM. If
this happens, the return value is not set to a negative value and the
module load will succeed. It will then crash on module unload because of
a destroy_workqueue() call on a NULL pointer.
Additionally, the _busy_wq workqueue is not being destroyed if any
errors happen on l2cap_init().
Signed-off-by: Anderson Lizardo <anderson.lizardo@openbossa.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/l2cap.c')
-rw-r--r-- | net/bluetooth/l2cap.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index 12b4aa2f8fc9..a1c7ae88dd1f 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c | |||
@@ -4871,8 +4871,10 @@ static int __init l2cap_init(void) | |||
4871 | return err; | 4871 | return err; |
4872 | 4872 | ||
4873 | _busy_wq = create_singlethread_workqueue("l2cap"); | 4873 | _busy_wq = create_singlethread_workqueue("l2cap"); |
4874 | if (!_busy_wq) | 4874 | if (!_busy_wq) { |
4875 | goto error; | 4875 | proto_unregister(&l2cap_proto); |
4876 | return -ENOMEM; | ||
4877 | } | ||
4876 | 4878 | ||
4877 | err = bt_sock_register(BTPROTO_L2CAP, &l2cap_sock_family_ops); | 4879 | err = bt_sock_register(BTPROTO_L2CAP, &l2cap_sock_family_ops); |
4878 | if (err < 0) { | 4880 | if (err < 0) { |
@@ -4900,6 +4902,7 @@ static int __init l2cap_init(void) | |||
4900 | return 0; | 4902 | return 0; |
4901 | 4903 | ||
4902 | error: | 4904 | error: |
4905 | destroy_workqueue(_busy_wq); | ||
4903 | proto_unregister(&l2cap_proto); | 4906 | proto_unregister(&l2cap_proto); |
4904 | return err; | 4907 | return err; |
4905 | } | 4908 | } |