Skip to contentSkip to conversation

Bluetooth: hci_uart: check the return value of recv()

PATCH In review Jiejing Zhang 2 participants 2 messages Apr 7, 2011 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: hci_uart: check the return value of recv()

Check the return value of hu->proto->recv() in hci_uart_tty_receive() the recv() may return error, check it, not add this to statistics.

---
 drivers/bluetooth/hci_ath.c   |    6 +++++-
 drivers/bluetooth/hci_ldisc.c |    6 ++++--
 2 files changed, 9 insertions(+), 3 deletions(-)
drivers/bluetooth/hci_ath.c +5 -1
index bd34406..caf807e 100644
@@ -201,8 +201,12 @@ static struct sk_buff *ath_dequeue(struct hci_uart *hu)
 /* Recv data */
 static int ath_recv(struct hci_uart *hu, void *data, int count)
 {
-	if (hci_recv_stream_fragment(hu->hdev, data, count) < 0)
+	int ret;
+	ret = hci_recv_stream_fragment(hu->hdev, data, count);
+	if (ret < 0) {
 		BT_ERR("Frame Reassembly Failed");
+		return ret;
+	}
 
 	return count;
 }
drivers/bluetooth/hci_ldisc.c +4 -2
index 48ad2a7..320f718 100644
@@ -359,6 +359,7 @@ static void hci_uart_tty_wakeup(struct tty_struct *tty)
  */
 static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, char *flags, int count)
 {
+	int ret;
 	struct hci_uart *hu = (void *)tty->disc_data;
 
 	if (!hu || tty != hu->tty)
@@ -368,8 +369,9 @@ static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, char *f
 		return;
 
 	spin_lock(&hu->rx_lock);
-	hu->proto->recv(hu, (void *) data, count);
-	hu->hdev->stat.byte_rx += count;
+	ret = hu->proto->recv(hu, (void *) data, count);
+	if (ret > 0)
+		hu->hdev->stat.byte_rx += count;
 	spin_unlock(&hu->rx_lock);
 
 	tty_unthrottle(tty);
Signature · 1 line
1.7.1
#1 lore raw

Hi Jiejing,

Quoted 8 lines · Jiejing Zhang

Check the return value of hu->proto->recv() in hci_uart_tty_receive() the recv() may return error, check it, not add this to statistics.

---
 drivers/bluetooth/hci_ath.c   |    6 +++++-
 drivers/bluetooth/hci_ldisc.c |    6 ++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

Patch has been applied. Thanks.

Signature · 2 lines
Gustavo F. Padovan
http://profusion.mobi