Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
hw/xen: Fix memory leak in libxenstore_open() for Xen
There was a superfluous allocation of the XS handle, leading to it
being leaked on both the error path and the success path (where it gets
allocated again).

Spotted by Coverity (CID 1508098).

Fixes: ba2a92d ("hw/xen: Add xenstore operations to allow redirection to internal emulation")
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Paul Durrant <paul@xen.org>
Message-Id: <20230412185102.441523-3-dwmw2@infradead.org>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
(cherry picked from commit 8442232)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
  • Loading branch information
dwmw2 authored and Michael Tokarev committed Jun 7, 2023
1 parent 903c712 commit 1797de7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hw/xen/xen-operations.c
Expand Up @@ -287,7 +287,7 @@ static void watch_event(void *opaque)
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);
struct qemu_xs_handle *h;

if (!xsh) {
return NULL;
Expand Down

0 comments on commit 1797de7

Please sign in to comment.