vhost_net: fix missing descriptor recovery
diff mbox series

Message ID 20190717115834.25988-1-huhai@kylinos.cn
State New
Headers show
Series
  • vhost_net: fix missing descriptor recovery
Related show

Commit Message

huhai July 17, 2019, 11:58 a.m. UTC
When get_tx_bufs get descriptor successful, but this descriptor have
some problem, we should inform the guest to recycle this descriptor,
instead of doing nothing.

Signed-off-by: huhai <huhai@kylinos.cn>
---
 drivers/vhost/net.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Jason Wang July 17, 2019, 12:35 p.m. UTC | #1
On 2019/7/17 下午7:58, huhai wrote:
> When get_tx_bufs get descriptor successful, but this descriptor have
> some problem, we should inform the guest to recycle this descriptor,
> instead of doing nothing.
>
> Signed-off-by: huhai <huhai@kylinos.cn>
> ---
>   drivers/vhost/net.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
> index 247e5585af5d..939a2ef9c223 100644
> --- a/drivers/vhost/net.c
> +++ b/drivers/vhost/net.c
> @@ -620,6 +620,7 @@ static int get_tx_bufs(struct vhost_net *net,
>   	if (*in) {
>   		vq_err(vq, "Unexpected descriptor format for TX: out %d, int %d\n",
>   			*out, *in);
> +		vhost_add_used_and_signal(&net->dev, vq, ret, 0);
>   		return -EFAULT;
>   	}
>   
> @@ -628,6 +629,7 @@ static int get_tx_bufs(struct vhost_net *net,
>   	if (*len == 0) {
>   		vq_err(vq, "Unexpected header len for TX: %zd expected %zd\n",
>   			*len, nvq->vhost_hlen);
> +		vhost_add_used_and_signal(&net->dev, vq, ret, 0);
>   		return -EFAULT;
>   	}
>   


This is usually a hint of driver bug. I believe it's better to fail 
explicitly here instead of trying to workaround it.

Thanks

Patch
diff mbox series

diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 247e5585af5d..939a2ef9c223 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -620,6 +620,7 @@  static int get_tx_bufs(struct vhost_net *net,
 	if (*in) {
 		vq_err(vq, "Unexpected descriptor format for TX: out %d, int %d\n",
 			*out, *in);
+		vhost_add_used_and_signal(&net->dev, vq, ret, 0);
 		return -EFAULT;
 	}
 
@@ -628,6 +629,7 @@  static int get_tx_bufs(struct vhost_net *net,
 	if (*len == 0) {
 		vq_err(vq, "Unexpected header len for TX: %zd expected %zd\n",
 			*len, nvq->vhost_hlen);
+		vhost_add_used_and_signal(&net->dev, vq, ret, 0);
 		return -EFAULT;
 	}