OSDN Git Service

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)
committerDavid S. Miller <davem@davemloft.net>
Wed, 23 May 2018 17:36:19 +0000 (13:36 -0400)
commit850e088d5bbb333342fd4def08d0a4035f2b7126
tree95c9ecea1c103d8e4279bd78fa0e569b87a7d64b
parent5d458a13dd59d04b4d6658a6d5b94d42732b15ae
virtio-net: correctly check num_buf during err path

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>
drivers/net/virtio_net.c