* [PATCH] Bluetooth: Fix HCI H5 corrupted ack value
@ 2014-08-08 17:07 Loic Poulain
2014-08-08 17:50 ` Marcel Holtmann
0 siblings, 1 reply; 2+ messages in thread
From: Loic Poulain @ 2014-08-08 17:07 UTC (permalink / raw)
To: marcel, gustavo, johan.hedberg; +Cc: linux-bluetooth, Loic Poulain
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>
---
drivers/bluetooth/hci_h5.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
index fede8ca..5d9148f 100644
--- a/drivers/bluetooth/hci_h5.c
+++ b/drivers/bluetooth/hci_h5.c
@@ -237,7 +237,7 @@ static void h5_pkt_cull(struct h5 *h5)
break;
to_remove--;
- seq = (seq - 1) % 8;
+ seq = (seq - 1) & 0x07;
}
if (seq != h5->rx_ack)
--
1.8.3.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Bluetooth: Fix HCI H5 corrupted ack value
2014-08-08 17:07 [PATCH] Bluetooth: Fix HCI H5 corrupted ack value Loic Poulain
@ 2014-08-08 17:50 ` Marcel Holtmann
0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2014-08-08 17:50 UTC (permalink / raw)
To: Loic Poulain; +Cc: Gustavo F. Padovan, Johan Hedberg, linux-bluetooth
Hi Loic,
> 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>
> ---
> drivers/bluetooth/hci_h5.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-08-08 17:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-08 17:07 [PATCH] Bluetooth: Fix HCI H5 corrupted ack value Loic Poulain
2014-08-08 17:50 ` Marcel Holtmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.