thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-vhost-user-blk-Make-sure-to-set-Error-on-realize-fai.patch

a83cc2
From f90c21b271d88733e604b3645986f8362048b0f0 Mon Sep 17 00:00:00 2001
a83cc2
From: Kevin Wolf <kwolf@redhat.com>
a83cc2
Date: Mon, 12 Jul 2021 10:22:26 -0400
a83cc2
Subject: [PATCH 06/43] vhost-user-blk: Make sure to set Error on realize
a83cc2
 failure
a83cc2
a83cc2
RH-Author: Miroslav Rezanina <mrezanin@redhat.com>
a83cc2
RH-Bugzilla: 1957194
a83cc2
a83cc2
We have to set errp before jumping to virtio_err, otherwise the caller
a83cc2
(virtio_device_realize()) will take this as success and crash when it
a83cc2
later tries to access things that we've already freed in the error path.
a83cc2
a83cc2
Fixes: 77542d431491788d1e8e79d93ce10172ef207775
a83cc2
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
a83cc2
Message-Id: <20210429171316.162022-2-kwolf@redhat.com>
a83cc2
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
a83cc2
Reviewed-by: Eric Blake <eblake@redhat.com>
a83cc2
Acked-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
a83cc2
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
a83cc2
(cherry picked from commit f26729715ef21325f972f693607580a829ad1cbb)
a83cc2
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
a83cc2
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
a83cc2
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
a83cc2
---
a83cc2
 hw/block/vhost-user-blk.c | 4 +---
a83cc2
 1 file changed, 1 insertion(+), 3 deletions(-)
a83cc2
a83cc2
diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
a83cc2
index f5e9682703..7c85248a7b 100644
a83cc2
--- a/hw/block/vhost-user-blk.c
a83cc2
+++ b/hw/block/vhost-user-blk.c
a83cc2
@@ -447,7 +447,6 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
a83cc2
 {
a83cc2
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
a83cc2
     VHostUserBlk *s = VHOST_USER_BLK(vdev);
a83cc2
-    Error *err = NULL;
a83cc2
     int i, ret;
a83cc2
 
a83cc2
     if (!s->chardev.chr) {
a83cc2
@@ -495,8 +494,7 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
a83cc2
                              NULL, true);
a83cc2
 
a83cc2
 reconnect:
a83cc2
-    if (qemu_chr_fe_wait_connected(&s->chardev, &err) < 0) {
a83cc2
-        error_report_err(err);
a83cc2
+    if (qemu_chr_fe_wait_connected(&s->chardev, errp) < 0) {
a83cc2
         goto virtio_err;
a83cc2
     }
a83cc2
 
a83cc2
-- 
a83cc2
2.27.0
a83cc2