git: 1cc96501e580 - main - bhyve: Fix a leak that happens when we fail to load a hostfwd rule
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 01 Dec 2023 15:01:13 UTC
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);
}