Skip to content

Commit 4e910db

Browse files
superjamiedavem330
authored andcommitted
qede: confirm skb is allocated before using
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: 8a86339 ("qede: Add build_skb() support.") Signed-off-by: Jamie Bainbridge <jamie.bainbridge@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a3ebe92 commit 4e910db

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/net/ethernet/qlogic/qede/qede_fp.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,9 @@ qede_build_skb(struct qede_rx_queue *rxq,
748748
buf = page_address(bd->data) + bd->page_offset;
749749
skb = build_skb(buf, rxq->rx_buf_seg_size);
750750

751+
if (unlikely(!skb))
752+
return NULL;
753+
751754
skb_reserve(skb, pad);
752755
skb_put(skb, len);
753756

0 commit comments

Comments
 (0)