Fuzzing found that ->set_config() could be called without connection.

Signed-off-by: Konstantin Khlebnikov <[email protected]>
---
 hw/block/vhost-user-blk.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
index 35ac188ca4..9ac50443bc 100644
--- a/hw/block/vhost-user-blk.c
+++ b/hw/block/vhost-user-blk.c
@@ -72,6 +72,10 @@ static void vhost_user_blk_set_config(VirtIODevice *vdev, 
const uint8_t *config)
     struct virtio_blk_config *blkcfg = (struct virtio_blk_config *)config;
     int ret;
 
+    if (!s->connected) {
+        return;
+    }
+
     if (blkcfg->wce == s->blkcfg.wce) {
         return;
     }


Reply via email to