diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2010-12-13 14:07:03 -0500 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2010-12-22 19:56:56 -0500 |
commit | e41d8b4e131a41f2a3b74aaa783b16aa46376d8e (patch) | |
tree | 19de1c961c684614a9631e4446bbb8265f63837d /net/bluetooth/mgmt.c | |
parent | a40c406cbdd28dcca3483065bc2ba794cf5aaab7 (diff) |
Bluetooth: Add error handling for managment command handlers
The command handlers for bluetooth management messaging should be able
to report errors (such as memory allocation failures) to the higher
levels in the call stack.
Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r-- | net/bluetooth/mgmt.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index d15bf676c350..7ea5489e7977 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <net/bluetooth/hci_core.h> | 29 | #include <net/bluetooth/hci_core.h> |
30 | #include <net/bluetooth/mgmt.h> | 30 | #include <net/bluetooth/mgmt.h> |
31 | 31 | ||
32 | static void cmd_status(struct sock *sk, u16 cmd, u8 status) | 32 | static int cmd_status(struct sock *sk, u16 cmd, u8 status) |
33 | { | 33 | { |
34 | struct sk_buff *skb; | 34 | struct sk_buff *skb; |
35 | struct mgmt_hdr *hdr; | 35 | struct mgmt_hdr *hdr; |
@@ -39,7 +39,7 @@ static void cmd_status(struct sock *sk, u16 cmd, u8 status) | |||
39 | 39 | ||
40 | skb = alloc_skb(sizeof(*hdr) + sizeof(*ev), GFP_ATOMIC); | 40 | skb = alloc_skb(sizeof(*hdr) + sizeof(*ev), GFP_ATOMIC); |
41 | if (!skb) | 41 | if (!skb) |
42 | return; | 42 | return -ENOMEM; |
43 | 43 | ||
44 | hdr = (void *) skb_put(skb, sizeof(*hdr)); | 44 | hdr = (void *) skb_put(skb, sizeof(*hdr)); |
45 | 45 | ||
@@ -52,6 +52,8 @@ static void cmd_status(struct sock *sk, u16 cmd, u8 status) | |||
52 | 52 | ||
53 | if (sock_queue_rcv_skb(sk, skb) < 0) | 53 | if (sock_queue_rcv_skb(sk, skb) < 0) |
54 | kfree_skb(skb); | 54 | kfree_skb(skb); |
55 | |||
56 | return 0; | ||
55 | } | 57 | } |
56 | 58 | ||
57 | int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) | 59 | int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) |
@@ -87,10 +89,13 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) | |||
87 | switch (opcode) { | 89 | switch (opcode) { |
88 | default: | 90 | default: |
89 | BT_DBG("Unknown op %u", opcode); | 91 | BT_DBG("Unknown op %u", opcode); |
90 | cmd_status(sk, opcode, 0x01); | 92 | err = cmd_status(sk, opcode, 0x01); |
91 | break; | 93 | break; |
92 | } | 94 | } |
93 | 95 | ||
96 | if (err < 0) | ||
97 | goto done; | ||
98 | |||
94 | err = msglen; | 99 | err = msglen; |
95 | 100 | ||
96 | done: | 101 | done: |