]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: fix potential resource leak
authorJonathon Jongsma <jjongsma@redhat.com>
Wed, 21 Oct 2020 21:50:06 +0000 (16:50 -0500)
committerLaine Stump <laine@redhat.com>
Fri, 23 Oct 2020 22:39:20 +0000 (18:39 -0400)
Coverity reported a potential resource leak. While it's probably not
a real-world scenario, the code could technically jump to cleanup
between the time that vdpafd is opened and when it is used. Ensure that
it gets cleaned up in that case.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
src/qemu/qemu_command.c

index e10121cf94d33e95994638c96a4e9408aecfc7a0..78477065945b052d1b8fc2771cfbf74bba3a5e11 100644 (file)
@@ -8145,6 +8145,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
         addfdarg = g_strdup_printf("%s,opaque=%s", fdset,
                                    net->data.vdpa.devicepath);
         virCommandAddArgList(cmd, "-add-fd", addfdarg, NULL);
+        vdpafd = -1;
     }
 
     if (chardev)
@@ -8214,6 +8215,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
     VIR_FREE(tapfdName);
     VIR_FREE(vhostfd);
     VIR_FREE(tapfd);
+    VIR_FORCE_CLOSE(vdpafd);
     return ret;
 }