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>
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) {
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)