]> xenbits.xensource.com Git - libvirt.git/commit
qemu: Fix handling of passed FDs in remoteDispatchDomainFdAssociate
authorPeter Krempa <pkrempa@redhat.com>
Tue, 10 Jan 2023 13:31:27 +0000 (14:31 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 10 Jan 2023 14:54:52 +0000 (15:54 +0100)
commitd7e909350210ce7f80a6bd5ab80a9bc067fdddbf
tree62cf485c3568ce7efbbc66c9b254cd151d2171ae
parent8f93d546d198c7dc47068dbc0f233aad28b0e33a
qemu: Fix handling of passed FDs in remoteDispatchDomainFdAssociate

To ensure same behaviour when remote driver is or is not used we must
not steal the FDs and array holding them passed to qemuDomainFDAssociate
but rather duplicate them. At the same time the remote driver must close
and free them to prevent leak.

Pointed out by Coverity as FD leak on error path:

 *** CID 404348:  Resource leaks  (RESOURCE_LEAK)
 /src/remote/remote_daemon_dispatch.c: 7484 in remoteDispatchDomainFdAssociate()
 7478         rv = 0;
 7479
 7480      cleanup:
 7481         if (rv < 0)
 7482             virNetMessageSaveError(rerr);
 7483         virObjectUnref(dom);
 >>>     CID 404348:  Resource leaks  (RESOURCE_LEAK)
 >>>     Variable "fds" going out of scope leaks the storage it points to.
 7484         return rv;

Fixes: abd9025c2fd
Fixes: f762f87534e
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_driver.c
src/remote/remote_daemon_dispatch.c