aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/mgmt.c
diff options
context:
space:
mode:
authorGustavo F. Padovan <padovan@profusion.mobi>2011-10-14 18:20:01 -0400
committerGustavo F. Padovan <padovan@profusion.mobi>2011-10-14 18:20:01 -0400
commit56b7d137855eb02cba8aecbb67d49c24b43644b0 (patch)
tree90bb9f0242a452dee0db1acb1ecc289ff44b0e46 /net/bluetooth/mgmt.c
parent33ca954daf1ac03c86237b73235d8b0856d84981 (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.c12
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
74static int cmd_complete(struct sock *sk, u16 index, u16 cmd, void *rp, 76static 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
105static int read_version(struct sock *sk) 109static int read_version(struct sock *sk)