From 00adced5c3166ee65b6880b48c1e0826b7304f76 Mon Sep 17 00:00:00 2001 From: Hanna Czenczek Date: Tue, 23 Jul 2024 18:39:39 +0200 Subject: virtio: Allow .get_vhost() without vhost_started Historically, .get_vhost() was probably only called when vdev->vhost_started is true. However, we now decidedly want to call it also when vhost_started is false, specifically so we can issue a reset to the vhost back-end while device operation is stopped. Some .get_vhost() implementations dereference some pointers (or return offsets from them) that are probably guaranteed to be non-NULL when vhost_started is true, but not necessarily otherwise. This patch makes all such implementations check all such pointers, returning NULL if any is NULL. Signed-off-by: Hanna Czenczek Message-Id: <20240723163941.48775-2-hreitz@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi --- hw/display/vhost-user-gpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw/display') diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index c0c6691..14548f1 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -642,7 +642,7 @@ vhost_user_gpu_device_realize(DeviceState *qdev, Error **errp) static struct vhost_dev *vhost_user_gpu_get_vhost(VirtIODevice *vdev) { VhostUserGPU *g = VHOST_USER_GPU(vdev); - return &g->vhost->dev; + return g->vhost ? &g->vhost->dev : NULL; } static Property vhost_user_gpu_properties[] = { -- cgit v1.1