]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
virtio-net: correctly check num_buf during err path
authorJason Wang <jasowang@redhat.com>
Tue, 22 May 2018 03:44:30 +0000 (11:44 +0800)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 5 Sep 2018 08:30:45 +0000 (10:30 +0200)
commit26f1676bdd995d2d8803a22e7a8f5d292908c4a3
treea4de76ff51ec9c2c89e7bb9b4e2e452dedbaf94d
parenteac5c3ccfa50c0bca959953eb3fe7f27555a5493
virtio-net: correctly check num_buf during err path

BugLink: http://bugs.launchpad.net/bugs/1789666
[ 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 <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/net/virtio_net.c