]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
vhost_net: fix ubuf refcount incorrectly when sendmsg fails
authorYunjian Wang <wangyunjian@huawei.com>
Tue, 29 Dec 2020 02:01:48 +0000 (10:01 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Jan 2021 19:16:16 +0000 (20:16 +0100)
commit5c6eb887e1929eef02c0e52e9312b7232de76c15
treea6fcf2b2fc8523aa6394c161f71e670c230ad26e
parent8f64957fda1280700057cdbc2d785e64901abb79
vhost_net: fix ubuf refcount incorrectly when sendmsg fails

[ Upstream commit 01e31bea7e622f1890c274f4aaaaf8bccd296aa5 ]

Currently the vhost_zerocopy_callback() maybe be called to decrease
the refcount when sendmsg fails in tun. The error handling in vhost
handle_tx_zerocopy() will try to decrease the same refcount again.
This is wrong. To fix this issue, we only call vhost_net_ubuf_put()
when vq->heads[nvq->desc].len == VHOST_DMA_IN_PROGRESS.

Fixes: bab632d69ee4 ("vhost: vhost TX zero-copy support")
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Link: https://lore.kernel.org/r/1609207308-20544-1-git-send-email-wangyunjian@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/vhost/net.c