aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Vivier <lvivier@redhat.com>2025-07-17 17:08:02 +0200
committerJason Wang <jasowang@redhat.com>2025-07-21 10:22:49 +0800
commitc40ef7243fdbec816242cb0ded569a61270ea7c3 (patch)
tree8fc6d03572800633da3e0633dc06c37c0e992c8a
parent37c8b208cc3161c2bcd4e2ff1e1077a64872ced3 (diff)
downloadqemu-c40ef7243fdbec816242cb0ded569a61270ea7c3.zip
qemu-c40ef7243fdbec816242cb0ded569a61270ea7c3.tar.gz
qemu-c40ef7243fdbec816242cb0ded569a61270ea7c3.tar.bz2
net/passt: Remove dead code in passt_vhost_user_start error path (CID 1612371)
In passt_vhost_user_start(), if vhost_net_init() fails, the "net" variable is NULL and execution jumps to the "err:" label. The cleanup code within this label is conditioned on "if (net)", which can never be true in this error case. This makes the cleanup block dead code, as reported by Coverity (CID 1612371). Refactor the error handling to occur inline, removing the goto and the unreachable cleanup block. Signed-off-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Jason Wang <jasowang@redhat.com>
-rw-r--r--net/passt.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/net/passt.c b/net/passt.c
index 9cd5b3e..ef59d06 100644
--- a/net/passt.c
+++ b/net/passt.c
@@ -375,7 +375,8 @@ static int passt_vhost_user_start(NetPasstState *s, VhostUserState *be)
net = vhost_net_init(&options);
if (!net) {
error_report("failed to init passt vhost_net");
- goto err;
+ passt_vhost_user_stop(s);
+ return -1;
}
if (s->vhost_net) {
@@ -385,13 +386,6 @@ static int passt_vhost_user_start(NetPasstState *s, VhostUserState *be)
s->vhost_net = net;
return 0;
-err:
- if (net) {
- vhost_net_cleanup(net);
- g_free(net);
- }
- passt_vhost_user_stop(s);
- return -1;
}
static void passt_vhost_user_event(void *opaque, QEMUChrEvent event)