bhyve: avoid resource leak in error path

In e820_finalize(), the e820_fwcfg_item variable, containing the
etc/e820 file (for the e820 table from the BIOS) is not free()'d when it
could not be added to the QEMU firmware configuration device (fw_cfg).

Reported by:	Coverity Scan
CID:		1522761
Reviewed by:	corvink, jhb
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45223
This commit is contained in:
Pierre Pronchery 2024-05-16 18:55:54 +02:00 committed by Ed Maste
parent 4ab122e8ef
commit e9806d2128

View file

@ -483,6 +483,8 @@ e820_finalize(void)
e820_fwcfg_item->size, e820_fwcfg_item->data);
if (error != 0) {
warnx("could not add qemu fwcfg etc/e820");
free(e820_fwcfg_item->data);
free(e820_fwcfg_item);
return (error);
}
free(e820_fwcfg_item);