Commit c460f057 authored by Jason Wang's avatar Jason Wang Committed by Michael S. Tsirkin

vhost_net: zerocopy: fix possible NULL pointer dereference of vq->bufs

When we want to disable vhost_net backend while there's a tx work, a possible
NULL pointer defernece may happen we we try to deference the vq->bufs after
vhost_net_set_backend() assign a NULL to it.

As suggested by Michael, fix this by checking the vq->bufs instead of
vhost_sock_zcopy().
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent b92946e2
...@@ -166,7 +166,7 @@ static void handle_tx(struct vhost_net *net) ...@@ -166,7 +166,7 @@ static void handle_tx(struct vhost_net *net)
if (wmem < sock->sk->sk_sndbuf / 2) if (wmem < sock->sk->sk_sndbuf / 2)
tx_poll_stop(net); tx_poll_stop(net);
hdr_size = vq->vhost_hlen; hdr_size = vq->vhost_hlen;
zcopy = vhost_sock_zcopy(sock); zcopy = vq->ubufs;
for (;;) { for (;;) {
/* Release DMAs done buffers first */ /* Release DMAs done buffers first */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment