提交 0e23db14 编写于 作者: J Jamie Bainbridge 提交者: Zheng Zengkai

qede: confirm skb is allocated before using

stable inclusion
from stable-v5.10.111
commit 8928239e5e2e460d95b8a0b89f61671625e7ece0
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5GL1Z

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=8928239e5e2e460d95b8a0b89f61671625e7ece0

--------------------------------

[ Upstream commit 4e910dbe ]

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: NJamie Bainbridge <jamie.bainbridge@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
上级 6ff374b0
...@@ -752,6 +752,9 @@ qede_build_skb(struct qede_rx_queue *rxq, ...@@ -752,6 +752,9 @@ qede_build_skb(struct qede_rx_queue *rxq,
buf = page_address(bd->data) + bd->page_offset; buf = page_address(bd->data) + bd->page_offset;
skb = build_skb(buf, rxq->rx_buf_seg_size); skb = build_skb(buf, rxq->rx_buf_seg_size);
if (unlikely(!skb))
return NULL;
skb_reserve(skb, pad); skb_reserve(skb, pad);
skb_put(skb, len); skb_put(skb, len);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册