bhyve: Fix a leak that happens when we fail to load a hostfwd rule

Reported by:	Coverity
Fixes:		c5359e2af5 ("bhyve: Add a slirp network backend")
This commit is contained in:
Mark Johnston 2023-12-01 09:46:31 -05:00
parent 4b0615e585
commit 1cc96501e5

View file

@ -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);
}