Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 1 Aug 2024 17:35:57 GMT
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 88069992b210 - stable/14 - bhyve: avoid resource leak in error path
Message-ID:  <202408011735.471HZvWk031736@gitrepo.freebsd.org>

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

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

commit 88069992b210f659327024babb80589d86a2c119
Author:     Pierre Pronchery <pierre@freebsdfoundation.org>
AuthorDate: 2024-05-16 16:55:54 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2024-08-01 17:34:50 +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
    
    (cherry picked from commit e9806d21282d3d5486b99b5c7062b490b00d8323)
---
 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?202408011735.471HZvWk031736>