Skip to content

Commit ec970a6

Browse files
nngt88jhedberg
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 <guotao.zhang@nxp.com>
1 parent 79faa6a commit ec970a6

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
@@ -338,7 +338,7 @@ static inline void read_payload(const struct device *dev)
338338
LOG_DBG("Allocated rx.buf %p", h4->rx.buf);
339339

340340
buf_tailroom = net_buf_tailroom(h4->rx.buf);
341-
if (buf_tailroom < h4->rx.remaining) {
341+
if (buf_tailroom < (h4->rx.remaining + h4->rx.hdr_len)) {
342342
LOG_ERR("Not enough space in buffer %u/%zu", h4->rx.remaining,
343343
buf_tailroom);
344344
h4->rx.discard = h4->rx.remaining;

0 commit comments

Comments
 (0)