From: Jason Wang Date: Tue, 22 May 2018 03:44:30 +0000 (+0800) Subject: virtio-net: correctly check num_buf during err path X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=155cd575588bca1ef1dd77e37386a737f4c0153e;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git virtio-net: correctly check num_buf during err path [ Upstream commit 850e088d5bbb333342fd4def08d0a4035f2b7126 ] If we successfully linearize the packet, num_buf will be set to zero which may confuse error handling path which assumes num_buf is at least 1 and this can lead the code tries to pop the descriptor of next buffer. Fixing this by checking num_buf against 1 before decreasing. Fixes: 4941d472bf95 ("virtio-net: do not reset during XDP set") Signed-off-by: Jason Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 925d15ea35cb..c5a1d221c49b 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -777,7 +777,7 @@ err_xdp: rcu_read_unlock(); err_skb: put_page(page); - while (--num_buf) { + while (num_buf-- > 1) { buf = virtqueue_get_buf(rq->vq, &len); if (unlikely(!buf)) { pr_debug("%s: rx error: %d buffers missing\n",