On Fri, 29 May 2026 at 05:59, Jason Wang <[email protected]> wrote:
>
> From: Vladimir Sementsov-Ogievskiy <[email protected]>
>
> Add common failure label. This:
>
> - simplifies failure paths in the function
> - get rid of unusual free_fail: in the middle of the function
> - simplify further refactoring

Hi; Coverity points out an issue with this patch (CID 160042).
Later changes have moved things about a bit but the part
that makes Coverity complain is:

> @@ -989,14 +965,13 @@ free_fail:
>              fd = net_tap_init(tap, &vnet_hdr, i >= 1 ? NULL : script,
>                                ifname, sizeof ifname, queues > 1, errp);
>              if (fd == -1) {
> -                return -1;
> +                goto fail;

Here we will go to the fail label if fd == -1...

>              }


> +
> +fail:
> +    close(fd);

...but at the fail label we unconditionally close(fd).
That's not valid if fd == -1.

> +    if (vhost_fds) {
> +        for (i = 0; i < nvhosts; i++) {
> +            g_free(vhost_fds[i]);
> +        }
> +        g_free(vhost_fds);
> +    }
> +    if (fds) {
> +        for (i = 0; i < nfds; i++) {
> +            g_free(fds[i]);
> +        }
> +        g_free(fds);
> +    }
> +    return -1;
>  }

thanks
-- PMM

Reply via email to