Commit e3b12d0c55e4 ("util/event_notifier: more strict API") added an
assert for an uninitialized file descriptor in event_notifier_get_fd(),
but it presumes that such a thing always exists.

Since it's only vhost_ops->vhost_set_config_call that expects to use
this file descriptor, move the retrieval of that fd inside the non-null
check to avoid an assertion failure when it does not exist.

Fixes: e3b12d0c55e4 ("util/event_notifier: more strict API")
Signed-off-by: Eric Farman <[email protected]>
---
 hw/virtio/vhost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index b25919c5c7d..998518c3b2e 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -2119,8 +2119,8 @@ static void vhost_start_config_intr(struct vhost_dev *dev)
         virtio_config_get_guest_notifier(dev->vdev);
 
     assert(dev->vhost_ops);
-    int fd = event_notifier_get_fd(config_notifier);
     if (dev->vhost_ops->vhost_set_config_call) {
+        int fd = event_notifier_get_fd(config_notifier);
         r = dev->vhost_ops->vhost_set_config_call(dev, fd);
         if (!r) {
             event_notifier_set(config_notifier);
-- 
2.53.0


Reply via email to