浏览代码

Bluetooth: Fix HCI H5 corrupted ack value

In this expression: seq = (seq - 1) % 8
seq (u8) is implicitly converted to an int in the arithmetic operation.
So if seq value is 0, operation is ((0 - 1) % 8) => (-1 % 8) => -1.
The new seq value is 0xff which is an invalid ACK value, we expect 0x07.
It leads to frequent dropped ACK and retransmission.
Fix this by using '&' binary operator instead of '%'.

Signed-off-by: Loic Poulain <loic.poulain@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Cc: stable@vger.kernel.org
Loic Poulain 11 年之前
父节点
当前提交
4807b51895
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      drivers/bluetooth/hci_h5.c

+ 1 - 1
drivers/bluetooth/hci_h5.c

@@ -237,7 +237,7 @@ static void h5_pkt_cull(struct h5 *h5)
 			break;
 			break;
 
 
 		to_remove--;
 		to_remove--;
-		seq = (seq - 1) % 8;
+		seq = (seq - 1) & 0x07;
 	}
 	}
 
 
 	if (seq != h5->rx_ack)
 	if (seq != h5->rx_ack)