Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 034a92c6 authored by Jamie Bainbridge's avatar Jamie Bainbridge Committed by Greg Kroah-Hartman
Browse files

qede: confirm skb is allocated before using



[ Upstream commit 4e910dbe36508654a896d5735b318c0b88172570 ]

qede_build_skb() assumes build_skb() always works and goes straight
to skb_reserve(). However, build_skb() can fail under memory pressure.
This results in a kernel panic because the skb to reserve is NULL.

Add a check in case build_skb() failed to allocate and return NULL.

The NULL return is handled correctly in callers to qede_build_skb().

Fixes: 8a863397 ("qede: Add build_skb() support.")
Signed-off-by: default avatarJamie Bainbridge <jamie.bainbridge@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 7ee84d29
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -723,6 +723,9 @@ qede_build_skb(struct qede_rx_queue *rxq,
	buf = page_address(bd->data) + bd->page_offset;
	skb = build_skb(buf, rxq->rx_buf_seg_size);

	if (unlikely(!skb))
		return NULL;

	skb_reserve(skb, pad);
	skb_put(skb, len);