diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index e84374b4cf..8d11972c88 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4698,6 +4698,8 @@ qemuBuildVideoCommandLine(virCommand *cmd,
g_autofree char *name = g_strdup_printf("%s-vhost-user", video->info.alias);
qemuDomainChrSourcePrivate *chrsrcpriv = QEMU_DOMAIN_CHR_SOURCE_PRIVATE(chrsrc);
+ if (chrsrc == NULL)
+ return -1;
chrsrc->type = VIR_DOMAIN_CHR_TYPE_UNIX;
chrsrcpriv->directfd = qemuFDPassDirectNew(name, &videopriv->vhost_user_fd);