Bluetooth: Fix HCI H5 corrupted ack value
authorLoic Poulain <loic.poulain@intel.com>
Fri, 8 Aug 2014 17:07:16 +0000 (19:07 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 Oct 2014 16:38:23 +0000 (09:38 -0700)
commit93d192a930c7b5bd97f1f77f90d298703896fdd3
treeaf3782ba4eefcb9098c9926362ce8f6e8b196571
parentc24580ec5132545788c48249f9d8fab758ee908c
Bluetooth: Fix HCI H5 corrupted ack value

commit 4807b51895dce8aa650ebebc51fa4a795ed6b8b8 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/bluetooth/hci_h5.c