Skip to content

Commit 9d7c235

Browse files
nngt88github-actions[bot]
authored andcommitted
drivers: bluetooth: h4: Fix check for sufficient buffer size
When alloc the evt buffer,such as the adv report, only compare the remaining data len, should aslo consider the hdr_len, because the hdr also copy to alloced buffer.if not consider the hdr, then hdr + remaining data may larger than alloced buffer, because the alloced buffer is not enough,then will assert when receive the remaining data. Signed-off-by: Guotao Zhang <[email protected]> (cherry picked from commit ec970a6)
1 parent 9bacf34 commit 9d7c235

File tree

1 file changed

+1
-1
lines changed
  • drivers/bluetooth/hci

1 file changed

+1
-1
lines changed

drivers/bluetooth/hci/h4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ static inline void read_payload(const struct device *dev)
312312
LOG_DBG("Allocated rx.buf %p", h4->rx.buf);
313313

314314
buf_tailroom = net_buf_tailroom(h4->rx.buf);
315-
if (buf_tailroom < h4->rx.remaining) {
315+
if (buf_tailroom < (h4->rx.remaining + h4->rx.hdr_len)) {
316316
LOG_ERR("Not enough space in buffer %u/%zu", h4->rx.remaining,
317317
buf_tailroom);
318318
h4->rx.discard = h4->rx.remaining;

0 commit comments

Comments
 (0)