Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 Dec 2023 15:01:13 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 1cc96501e580 - main - bhyve: Fix a leak that happens when we fail to load a hostfwd rule
Message-ID:  <202312011501.3B1F1DDF006132@gitrepo.freebsd.org>

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

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

commit 1cc96501e58057fba62cdebd514cdc9197d6e97c
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-12-01 14:46:31 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-12-01 14:46:31 +0000

    bhyve: Fix a leak that happens when we fail to load a hostfwd rule
    
    Reported by:    Coverity
    Fixes:          c5359e2af5ab ("bhyve: Add a slirp network backend")
---
 usr.sbin/bhyve/net_backend_slirp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/usr.sbin/bhyve/net_backend_slirp.c b/usr.sbin/bhyve/net_backend_slirp.c
index 1c414f87084c..1d6ed45b90f2 100644
--- a/usr.sbin/bhyve/net_backend_slirp.c
+++ b/usr.sbin/bhyve/net_backend_slirp.c
@@ -502,8 +502,10 @@ _slirp_init(struct net_backend *be, const char *devname __unused,
 			goto err;
 		while ((rule = strsep(&rules, ";")) != NULL) {
 			error = config_one_hostfwd(priv, rule);
-			if (error != 0)
+			if (error != 0) {
+				free(tofree);
 				goto err;
+			}
 		}
 		free(tofree);
 	}



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