diff mbox series

vl: fix "type is NULL" in -vga help

Message ID 20240515112512.1100498-1-marcandre.lureau@redhat.com (mailing list archive)
State New
Headers show
Series vl: fix "type is NULL" in -vga help | expand

Commit Message

Marc-André Lureau May 15, 2024, 11:25 a.m. UTC
From: Marc-André Lureau <marcandre.lureau@redhat.com>

A VGA interface is available if it has no class_names, or we can look up
any of the names - we shouldn't call module_object_class_by_name(NULL),
as happening for ex with TCX or CG3 on x86.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 system/vl.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/system/vl.c b/system/vl.c
index a3eede5fa5..398f88b0f0 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -999,9 +999,16 @@  static bool vga_interface_available(VGAInterfaceType t)
     const VGAInterfaceInfo *ti = &vga_interfaces[t];
 
     assert(t < VGA_TYPE_MAX);
-    return !ti->class_names[0] ||
-           module_object_class_by_name(ti->class_names[0]) ||
-           module_object_class_by_name(ti->class_names[1]);
+
+    if (!ti->class_names[0] || module_object_class_by_name(ti->class_names[0])) {
+        return true;
+    }
+
+    if (ti->class_names[1] && module_object_class_by_name(ti->class_names[1])) {
+        return true;
+    }
+
+    return false;
 }
 
 static const char *