emulator: fix potential resource leak

This patch releases the allocated fd to prevent the potential resource
leak. This was reported by the Coverity scan.
This commit is contained in:
Tedd Ho-Jeong An 2021-11-15 22:49:49 -08:00 committed by Luiz Augusto von Dentz
parent f59a6d4a4e
commit 270c8d07a0

View File

@ -140,8 +140,10 @@ struct vhci *vhci_open(uint8_t type)
}
vhci = malloc(sizeof(*vhci));
if (!vhci)
if (!vhci) {
close(fd);
return NULL;
}
memset(vhci, 0, sizeof(*vhci));
vhci->type = type;