diff options
author | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-10-14 18:20:01 -0400 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-10-14 18:20:01 -0400 |
commit | 56b7d137855eb02cba8aecbb67d49c24b43644b0 (patch) | |
tree | 90bb9f0242a452dee0db1acb1ecc289ff44b0e46 /net/bluetooth/mgmt.c | |
parent | 33ca954daf1ac03c86237b73235d8b0856d84981 (diff) |
Bluetooth: return proper error if sock_queue_rcv_skb() fails
Improve error handling at cmd_status() and cmd_complete()
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r-- | net/bluetooth/mgmt.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 5a94eec06caa..42e26146a9a6 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -48,6 +48,7 @@ static int cmd_status(struct sock *sk, u16 index, u16 cmd, u8 status) | |||
48 | struct sk_buff *skb; | 48 | struct sk_buff *skb; |
49 | struct mgmt_hdr *hdr; | 49 | struct mgmt_hdr *hdr; |
50 | struct mgmt_ev_cmd_status *ev; | 50 | struct mgmt_ev_cmd_status *ev; |
51 | int err; | ||
51 | 52 | ||
52 | BT_DBG("sock %p, index %u, cmd %u, status %u", sk, index, cmd, status); | 53 | BT_DBG("sock %p, index %u, cmd %u, status %u", sk, index, cmd, status); |
53 | 54 | ||
@@ -65,10 +66,11 @@ static int cmd_status(struct sock *sk, u16 index, u16 cmd, u8 status) | |||
65 | ev->status = status; | 66 | ev->status = status; |
66 | put_unaligned_le16(cmd, &ev->opcode); | 67 | put_unaligned_le16(cmd, &ev->opcode); |
67 | 68 | ||
68 | if (sock_queue_rcv_skb(sk, skb) < 0) | 69 | err = sock_queue_rcv_skb(sk, skb); |
70 | if (err < 0) | ||
69 | kfree_skb(skb); | 71 | kfree_skb(skb); |
70 | 72 | ||
71 | return 0; | 73 | return err; |
72 | } | 74 | } |
73 | 75 | ||
74 | static int cmd_complete(struct sock *sk, u16 index, u16 cmd, void *rp, | 76 | static int cmd_complete(struct sock *sk, u16 index, u16 cmd, void *rp, |
@@ -77,6 +79,7 @@ static int cmd_complete(struct sock *sk, u16 index, u16 cmd, void *rp, | |||
77 | struct sk_buff *skb; | 79 | struct sk_buff *skb; |
78 | struct mgmt_hdr *hdr; | 80 | struct mgmt_hdr *hdr; |
79 | struct mgmt_ev_cmd_complete *ev; | 81 | struct mgmt_ev_cmd_complete *ev; |
82 | int err; | ||
80 | 83 | ||
81 | BT_DBG("sock %p", sk); | 84 | BT_DBG("sock %p", sk); |
82 | 85 | ||
@@ -96,10 +99,11 @@ static int cmd_complete(struct sock *sk, u16 index, u16 cmd, void *rp, | |||
96 | if (rp) | 99 | if (rp) |
97 | memcpy(ev->data, rp, rp_len); | 100 | memcpy(ev->data, rp, rp_len); |
98 | 101 | ||
99 | if (sock_queue_rcv_skb(sk, skb) < 0) | 102 | err = sock_queue_rcv_skb(sk, skb); |
103 | if (err < 0) | ||
100 | kfree_skb(skb); | 104 | kfree_skb(skb); |
101 | 105 | ||
102 | return 0; | 106 | return err;; |
103 | } | 107 | } |
104 | 108 | ||
105 | static int read_version(struct sock *sk) | 109 | static int read_version(struct sock *sk) |