Commit 56b7d137 authored by Gustavo F. Padovan's avatar Gustavo F. Padovan

Bluetooth: return proper error if sock_queue_rcv_skb() fails

Improve error handling at cmd_status() and cmd_complete()
Signed-off-by: default avatarGustavo F. Padovan <padovan@profusion.mobi>
parent 33ca954d
...@@ -48,6 +48,7 @@ static int cmd_status(struct sock *sk, u16 index, u16 cmd, u8 status) ...@@ -48,6 +48,7 @@ static int cmd_status(struct sock *sk, u16 index, u16 cmd, u8 status)
struct sk_buff *skb; struct sk_buff *skb;
struct mgmt_hdr *hdr; struct mgmt_hdr *hdr;
struct mgmt_ev_cmd_status *ev; struct mgmt_ev_cmd_status *ev;
int err;
BT_DBG("sock %p, index %u, cmd %u, status %u", sk, index, cmd, status); BT_DBG("sock %p, index %u, cmd %u, status %u", sk, index, cmd, status);
...@@ -65,10 +66,11 @@ static int cmd_status(struct sock *sk, u16 index, u16 cmd, u8 status) ...@@ -65,10 +66,11 @@ static int cmd_status(struct sock *sk, u16 index, u16 cmd, u8 status)
ev->status = status; ev->status = status;
put_unaligned_le16(cmd, &ev->opcode); put_unaligned_le16(cmd, &ev->opcode);
if (sock_queue_rcv_skb(sk, skb) < 0) err = sock_queue_rcv_skb(sk, skb);
if (err < 0)
kfree_skb(skb); kfree_skb(skb);
return 0; return err;
} }
static int cmd_complete(struct sock *sk, u16 index, u16 cmd, void *rp, 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,6 +79,7 @@ static int cmd_complete(struct sock *sk, u16 index, u16 cmd, void *rp,
struct sk_buff *skb; struct sk_buff *skb;
struct mgmt_hdr *hdr; struct mgmt_hdr *hdr;
struct mgmt_ev_cmd_complete *ev; struct mgmt_ev_cmd_complete *ev;
int err;
BT_DBG("sock %p", sk); BT_DBG("sock %p", sk);
...@@ -96,10 +99,11 @@ static int cmd_complete(struct sock *sk, u16 index, u16 cmd, void *rp, ...@@ -96,10 +99,11 @@ static int cmd_complete(struct sock *sk, u16 index, u16 cmd, void *rp,
if (rp) if (rp)
memcpy(ev->data, rp, rp_len); memcpy(ev->data, rp, rp_len);
if (sock_queue_rcv_skb(sk, skb) < 0) err = sock_queue_rcv_skb(sk, skb);
if (err < 0)
kfree_skb(skb); kfree_skb(skb);
return 0; return err;;
} }
static int read_version(struct sock *sk) static int read_version(struct sock *sk)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment