Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 May 2024 16:26:58 GMT
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: e9806d21282d - main - bhyve: avoid resource leak in error path
Message-ID:  <202405171626.44HGQwrd082975@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=e9806d21282d3d5486b99b5c7062b490b00d8323

commit e9806d21282d3d5486b99b5c7062b490b00d8323
Author:     Pierre Pronchery <pierre@freebsdfoundation.org>
AuthorDate: 2024-05-16 16:55:54 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2024-05-17 16:26:27 +0000

    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
---
 usr.sbin/bhyve/amd64/e820.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/usr.sbin/bhyve/amd64/e820.c b/usr.sbin/bhyve/amd64/e820.c
index 456ce0330b50..9d95ec8ce688 100644
--- a/usr.sbin/bhyve/amd64/e820.c
+++ b/usr.sbin/bhyve/amd64/e820.c
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202405171626.44HGQwrd082975>