virtio_net: fix memory leak inside XPD_TX with mergeable
authorXuan Zhuo <xuanzhuo@linux.alibaba.com>
Thu, 4 Aug 2022 06:32:48 +0000 (14:32 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Aug 2022 09:40:06 +0000 (11:40 +0200)
commitd3723eab11196475ef83279571b2b0bd0924cf82
tree9aa16d3cde9de5cd04587687e8d271181976427d
parent9721e238c24cdc0e4aeec9cc82a0869740e626eb
virtio_net: fix memory leak inside XPD_TX with mergeable

commit 7a542bee27c6a57e45c33cbbdc963325fd6493af upstream.

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: 44fa2dbd4759 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/virtio_net.c