Commit 55c2d46
nimble/host: Fix race in HCI ACL TX outstanding packets counter
The outstanding packets counter (bhc_outstanding_pkts / avail_pkts)
was decremented after ble_hs_tx_data() returned. However, by that
point the controller may have already processed the packet and sent
a Number of Completed Packets event, which increments avail_pkts.
This race can cause avail_pkts to momentarily exceed the controller
maximum, leading to buffer overflows.
Move the counter update before ble_hs_tx_data() and roll back on
error.
Forward-port of espressif@f5136d2b31 parent e49531b commit 55c2d46
1 file changed
Lines changed: 9 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
560 | 560 | | |
561 | 561 | | |
562 | 562 | | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
563 | 570 | | |
564 | 571 | | |
| 572 | + | |
| 573 | + | |
565 | 574 | | |
566 | 575 | | |
567 | 576 | | |
| |||
570 | 579 | | |
571 | 580 | | |
572 | 581 | | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | 582 | | |
578 | 583 | | |
579 | 584 | | |
| |||
0 commit comments