qede: confirm skb is allocated before using
authorJamie Bainbridge <jamie.bainbridge@gmail.com>
Wed, 6 Apr 2022 11:19:19 +0000 (21:19 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Apr 2022 18:03:17 +0000 (20:03 +0200)
commitb2d6b3db9d1cf80908964036dbe1c52a86b1afb1
tree7079434d15feffb00b3c4610d529835c295687a9
parent9f730a70295369c538aeeff29aa1d9ca64b056a9
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: 8a8633978b842 ("qede: Add build_skb() support.")
Signed-off-by: Jamie Bainbridge <jamie.bainbridge@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/qlogic/qede/qede_fp.c