From: Jonathon Jongsma Date: Wed, 21 Oct 2020 21:50:06 +0000 (-0500) Subject: qemu: fix potential resource leak X-Git-Tag: v6.9.0-rc1~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4648736bea94c7893dafc80fc6ba6a96ae980a5;p=thirdparty%2Flibvirt.git qemu: fix potential resource leak 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 Reviewed-by: Laine Stump --- diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e10121cf94..7847706594 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -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; }