On Tue, 7 Mar 2023 at 18:27, David Woodhouse <[email protected]> wrote:
>
> From: Paul Durrant <[email protected]>
>
> Signed-off-by: Paul Durrant <[email protected]>
> Signed-off-by: David Woodhouse <[email protected]>
> Reviewed-by: Paul Durrant <[email protected]>
> ---
Hi; Coverity points out a memory leak in this code (CID 1508098):
> +static struct qemu_xs_handle *libxenstore_open(void)
> +{
> + struct xs_handle *xsh = xs_open(0);
> + struct qemu_xs_handle *h = g_new0(struct qemu_xs_handle, 1);
Here we allocate memory...
> +
> + if (!xsh) {
> + return NULL;
...but here we can return without freeing it...
> + }
> +
> + h = g_new0(struct qemu_xs_handle, 1);
...and here we allocate a second time and overwrite the
pointer to the first allocation.
Deleting the first call to g_new0() would fix both of these.
> + h->xsh = xsh;
> +
> + notifier_list_init(&h->notifiers);
> + qemu_set_fd_handler(xs_fileno(h->xsh), watch_event, NULL, h);
> +
> + return h;
> +}
thanks
-- PMM