mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
virtio_net: fix memory leak inside XPD_TX with mergeable
When we call xdp_convert_buff_to_frame() to get xdpf, if it returns
NULL, we should check if xdp_page was allocated by xdp_linearize_page().
If it is newly allocated, it should be freed here alone. Just like any
other "goto err_xdp".
Fixes: 44fa2dbd47
("xdp: transition into using xdp_frame for ndo_xdp_xmit")
Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
ac0dbed9ba
commit
7a542bee27
1 changed files with 4 additions and 1 deletions
|
@ -1057,8 +1057,11 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
|
||||||
case XDP_TX:
|
case XDP_TX:
|
||||||
stats->xdp_tx++;
|
stats->xdp_tx++;
|
||||||
xdpf = xdp_convert_buff_to_frame(&xdp);
|
xdpf = xdp_convert_buff_to_frame(&xdp);
|
||||||
if (unlikely(!xdpf))
|
if (unlikely(!xdpf)) {
|
||||||
|
if (unlikely(xdp_page != page))
|
||||||
|
put_page(xdp_page);
|
||||||
goto err_xdp;
|
goto err_xdp;
|
||||||
|
}
|
||||||
err = virtnet_xdp_xmit(dev, 1, &xdpf, 0);
|
err = virtnet_xdp_xmit(dev, 1, &xdpf, 0);
|
||||||
if (unlikely(!err)) {
|
if (unlikely(!err)) {
|
||||||
xdp_return_frame_rx_napi(xdpf);
|
xdp_return_frame_rx_napi(xdpf);
|
||||||
|
|
Loading…
Add table
Reference in a new issue