Skip to content

Commit 45eff64

Browse files
rluboskrish2718
authored andcommitted
[nrf fromtree] net: pkt: Fix fixed buffer allocation with headroom bug
The size calculation for the first buffer, in case extra headroom is requested, had a bug which could result in a size variable underflow followed by net_buf exhaustion. In case the net_buf size was larger than requested size, but smaller than requested size + headroom, the whole buffer size was subtracted from the requested size. This however did not take the extra headroom into account and in effect could result in underflow. Signed-off-by: Robert Lubos <[email protected]> (cherry picked from commit ea191bd) (cherry picked from commit 81eaa46)
1 parent 40ae990 commit 45eff64

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

subsys/net/ip/net_pkt.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ static struct net_buf *pkt_alloc_buffer(struct net_pkt *pkt,
970970

971971
size = 0U;
972972
} else {
973-
size -= current->size;
973+
size -= current->size - headroom;
974974
}
975975
} else {
976976
if (current->size > size) {

0 commit comments

Comments
 (0)