summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAnderson Lizardo <anderson.lizardo@openbossa.org>2010-11-29 12:15:50 -0400
committerGustavo F. Padovan <padovan@profusion.mobi>2010-12-01 21:04:43 -0200
commitb78d7b4f204a6ba1901af36c95e10fded9816054 (patch)
tree7c9106a631778aee9ffdeca94e0054a5fe818412 /net
parenteeb366564be7c311b31c70821d18a43a8a57f9bc (diff)
downloadop-kernel-dev-b78d7b4f204a6ba1901af36c95e10fded9816054.zip
op-kernel-dev-b78d7b4f204a6ba1901af36c95e10fded9816054.tar.gz
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')
-rw-r--r--net/bluetooth/l2cap.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index 12b4aa2..a1c7ae8 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -4871,8 +4871,10 @@ static int __init l2cap_init(void)
return err;
_busy_wq = create_singlethread_workqueue("l2cap");
- if (!_busy_wq)
- goto error;
+ if (!_busy_wq) {
+ proto_unregister(&l2cap_proto);
+ return -ENOMEM;
+ }
err = bt_sock_register(BTPROTO_L2CAP, &l2cap_sock_family_ops);
if (err < 0) {
@@ -4900,6 +4902,7 @@ static int __init l2cap_init(void)
return 0;
error:
+ destroy_workqueue(_busy_wq);
proto_unregister(&l2cap_proto);
return err;
}
OpenPOWER on IntegriCloud