]> git.baikalelectronics.ru Git - kernel.git/commitdiff
qede: confirm skb is allocated before using
authorJamie Bainbridge <jamie.bainbridge@gmail.com>
Wed, 6 Apr 2022 11:19:19 +0000 (21:19 +1000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 6 Apr 2022 14:16:23 +0000 (15:16 +0100)
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: c84f1b7b0321b ("qede: Add build_skb() support.")
Signed-off-by: Jamie Bainbridge <jamie.bainbridge@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qlogic/qede/qede_fp.c

index b242000a77fd8db322672e541df074be9b5ce9ef..b7cc36589f592e995e3a12bb80bc7c8e3af7dc42 100644 (file)
@@ -748,6 +748,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);