提交 2df01200 编写于 作者: D David Herrmann 提交者: Gustavo Padovan

Bluetooth: hidp: handle kernel_sendmsg() errors correctly

We shouldn't push back the skbs if kernel_sendmsg() fails. Instead, we
terminate the connection and drop the skb. Only on EAGAIN we push it back
and return.
l2cap doesn't return EAGAIN, yet, but this guarantees we're safe if it
will at some time in the future.
Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
Acked-by: NMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: NGustavo Padovan <gustavo.padovan@collabora.co.uk>
上级 5205185d
......@@ -639,13 +639,19 @@ static int hidp_send_frame(struct socket *sock, unsigned char *data, int len)
static void hidp_process_intr_transmit(struct hidp_session *session)
{
struct sk_buff *skb;
int ret;
BT_DBG("session %p", session);
while ((skb = skb_dequeue(&session->intr_transmit))) {
if (hidp_send_frame(session->intr_sock, skb->data, skb->len) < 0) {
ret = hidp_send_frame(session->intr_sock, skb->data, skb->len);
if (ret == -EAGAIN) {
skb_queue_head(&session->intr_transmit, skb);
break;
} else if (ret < 0) {
hidp_session_terminate(session);
kfree_skb(skb);
break;
}
hidp_set_timer(session);
......@@ -656,13 +662,19 @@ static void hidp_process_intr_transmit(struct hidp_session *session)
static void hidp_process_ctrl_transmit(struct hidp_session *session)
{
struct sk_buff *skb;
int ret;
BT_DBG("session %p", session);
while ((skb = skb_dequeue(&session->ctrl_transmit))) {
if (hidp_send_frame(session->ctrl_sock, skb->data, skb->len) < 0) {
ret = hidp_send_frame(session->ctrl_sock, skb->data, skb->len);
if (ret == -EAGAIN) {
skb_queue_head(&session->ctrl_transmit, skb);
break;
} else if (ret < 0) {
hidp_session_terminate(session);
kfree_skb(skb);
break;
}
hidp_set_timer(session);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册