net/slirp: fix leaks on forwarding rule registration error

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
This commit is contained in:
Marc-André Lureau 2019-01-17 15:43:36 +04:00 committed by Samuel Thibault
parent 8d45a3b946
commit 8e207c327c

View File

@ -807,6 +807,7 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str, Error **errp)
qemu_chr_fe_init(&fwd->hd, chr, &err);
if (err) {
error_propagate(errp, err);
object_unparent(OBJECT(chr));
g_free(fwd);
return -1;
}
@ -815,6 +816,7 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str, Error **errp)
&server, port) < 0) {
error_setg(errp, "Conflicting/invalid host:port in guest "
"forwarding rule '%s'", config_str);
qemu_chr_fe_deinit(&fwd->hd, true);
g_free(fwd);
return -1;
}