From: David Woodhouse Date: Wed, 12 Apr 2023 18:50:59 +0000 (+0100) Subject: hw/xen: Fix memory leak in libxenstore_open() for Xen X-Git-Tag: v8.0.3~42 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1797de7f825fb42118eaee55b874c2230b89e412;p=thirdparty%2Fqemu.git 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: ba2a92db1ff6 ("hw/xen: Add xenstore operations to allow redirection to internal emulation") Suggested-by: Peter Maydell Signed-off-by: David Woodhouse Reviewed-by: Peter Maydell Reviewed-by: Paul Durrant Message-Id: <20230412185102.441523-3-dwmw2@infradead.org> Signed-off-by: Anthony PERARD (cherry picked from commit 8442232eba1b041b379ca5845df8252c1e905e43) Signed-off-by: Michael Tokarev --- diff --git a/hw/xen/xen-operations.c b/hw/xen/xen-operations.c index 4b78fbf4bdf..3d213d28dfa 100644 --- a/hw/xen/xen-operations.c +++ b/hw/xen/xen-operations.c @@ -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;