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