diff mbox

[v2,5/9] virtio-net: handle virtio_net_handle_ctrl() error

Message ID 147447704939.30952.17919307218318456297.stgit@bahia (mailing list archive)
State New, archived
Headers show

Commit Message

Greg Kurz Sept. 21, 2016, 4:57 p.m. UTC
This error is caused by a buggy guest: let's switch the device to the
broken state instead of terminating QEMU.

Signed-off-by: Greg Kurz <groug@kaod.org>
---
v2: - s/return/break in virtio_net_handle_ctrl() for consistency's sake
---
 hw/net/virtio-net.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Cornelia Huck Sept. 22, 2016, 1:45 p.m. UTC | #1
On Wed, 21 Sep 2016 18:57:29 +0200
Greg Kurz <groug@kaod.org> wrote:

> This error is caused by a buggy guest: let's switch the device to the
> broken state instead of terminating QEMU.
> 
> Signed-off-by: Greg Kurz <groug@kaod.org>
> ---
> v2: - s/return/break in virtio_net_handle_ctrl() for consistency's sake
> ---
>  hw/net/virtio-net.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Stefan Hajnoczi Sept. 23, 2016, 1:07 p.m. UTC | #2
On Wed, Sep 21, 2016 at 06:57:29PM +0200, Greg Kurz wrote:
> This error is caused by a buggy guest: let's switch the device to the
> broken state instead of terminating QEMU.
> 
> Signed-off-by: Greg Kurz <groug@kaod.org>
> ---
> v2: - s/return/break in virtio_net_handle_ctrl() for consistency's sake
> ---
>  hw/net/virtio-net.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index 01f1351554aa..8a6f1d952467 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -892,8 +892,8 @@ static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
>          }
>          if (iov_size(elem->in_sg, elem->in_num) < sizeof(status) ||
>              iov_size(elem->out_sg, elem->out_num) < sizeof(ctrl)) {
> -            error_report("virtio-net ctrl missing headers");
> -            exit(1);
> +            virtio_error(vdev, "virtio-net ctrl missing headers");
> +            break;

We must detach and free elem to avoid leaks.
diff mbox

Patch

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 01f1351554aa..8a6f1d952467 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -892,8 +892,8 @@  static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
         }
         if (iov_size(elem->in_sg, elem->in_num) < sizeof(status) ||
             iov_size(elem->out_sg, elem->out_num) < sizeof(ctrl)) {
-            error_report("virtio-net ctrl missing headers");
-            exit(1);
+            virtio_error(vdev, "virtio-net ctrl missing headers");
+            break;
         }
 
         iov_cnt = elem->out_num;