aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorGravatar Xuan Zhuo <xuanzhuo@linux.alibaba.com> 2023-03-15 09:52:23 +0800
committerGravatar David S. Miller <davem@davemloft.net> 2023-03-16 17:46:05 +0000
commit1a3bd6eabae35afc5c6dbe2651f21467cf8ad3fd (patch)
treeeed998615148778f45fa25a5b1511e6ea2f3d0b5 /drivers
parentvirtio_net: fix page_to_skb() miss headroom (diff)
downloadlinux-1a3bd6eabae35afc5c6dbe2651f21467cf8ad3fd.tar.gz
linux-1a3bd6eabae35afc5c6dbe2651f21467cf8ad3fd.tar.bz2
linux-1a3bd6eabae35afc5c6dbe2651f21467cf8ad3fd.zip
virtio_net: free xdp shinfo frags when build_skb_from_xdp_buff() fails
build_skb_from_xdp_buff() may return NULL, in this case we need to free the frags of xdp shinfo. Fixes: fab89bafa95b ("virtio-net: support multi-buffer xdp") Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Yunsheng Lin <linyunsheng@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/virtio_net.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 8ecf7a341d54..2396c28c0122 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1273,9 +1273,12 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
switch (act) {
case XDP_PASS:
+ head_skb = build_skb_from_xdp_buff(dev, vi, &xdp, xdp_frags_truesz);
+ if (unlikely(!head_skb))
+ goto err_xdp_frags;
+
if (unlikely(xdp_page != page))
put_page(page);
- head_skb = build_skb_from_xdp_buff(dev, vi, &xdp, xdp_frags_truesz);
rcu_read_unlock();
return head_skb;
case XDP_TX: