@samitouri / QOSamiQemu / commits / 555d0a1eba

hw/display/virtio-gpu: drop redundant node->value NULL checks

QAPI-generated list visitors guarantee that node->value is never NULL: the input visitor allocates it via g_malloc0() in visit_start_struct(), and on failure the entire list parse is aborted and freed. Remove the unnecessary NULL checks from both callsites iterating g->conf.outputs. Resolves: Coverity CID 1664272 Fixes: 8dc8449a678f ("hw/display/virtio-gpu: Avoid leaking migration blocker") Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-ID: <20260730114751.3515083-1-marcandre.lureau@redhat.com>

Marc-André Lureau committed Jul 30, 2026 at 15:47 UTC 555d0a1eba204085e20421cd93a55276a21b8e5f
1 file changed +2 -2
hw/display/virtio-gpu-base.c
+2 -2
@@ -69,7 +69,7 @@ virtio_gpu_base_generate_edid(VirtIOGPUBase *g, int scanout,
69
70 for (output_idx = 0, node = g->conf.outputs;
71 output_idx <= scanout && node; output_idx++, node = node->next) {
72 - if (output_idx == scanout && node->value && node->value->name) {
72 + if (output_idx == scanout && node->value->name) {
73 info.name = node->value->name;
74 break;
75 }
@@ -206,7 +206,7 @@ virtio_gpu_base_device_realize(DeviceState *qdev,
206 error_setg(errp, "invalid outputs > %d", g->conf.max_outputs);
207 return false;
208 }
209 - if (node->value && node->value->name &&
209 + if (node->value->name &&
210 strlen(node->value->name) > EDID_NAME_MAX_LENGTH) {
211 error_setg(errp, "invalid output name '%s' > %d",
212 node->value->name, EDID_NAME_MAX_LENGTH);