[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/5] hw/xen: Fix memory leak in libxenstore_open() for Xen
From: |
David Woodhouse |
Subject: |
[PATCH 2/5] hw/xen: Fix memory leak in libxenstore_open() for Xen |
Date: |
Wed, 12 Apr 2023 19:50:59 +0100 |
From: David Woodhouse <dwmw@amazon.co.uk>
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 <peter.maydell@linaro.org>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/xen/xen-operations.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/xen/xen-operations.c b/hw/xen/xen-operations.c
index 4b78fbf4bd..3d213d28df 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;
--
2.39.2
- [PATCH for-8.0 0/5] Xen emulation build/Coverity fixes, David Woodhouse, 2023/04/12
- [PATCH 5/5] hw/xen: Fix broken check for invalid state in xs_be_open(), David Woodhouse, 2023/04/12
- [PATCH 1/5] hw/xen: Simplify emulated Xen platform init, David Woodhouse, 2023/04/12
- [PATCH 4/5] hw/xen: Fix double-free in xen_console store_con_info(), David Woodhouse, 2023/04/12
- [PATCH 2/5] hw/xen: Fix memory leak in libxenstore_open() for Xen,
David Woodhouse <=
- [PATCH 3/5] xen: Drop support for Xen versions below 4.7.1, David Woodhouse, 2023/04/12
- Re: [PATCH for-8.0 0/5] Xen emulation build/Coverity fixes, Peter Maydell, 2023/04/12
- Re: [PATCH for-8.0 0/5] Xen emulation build/Coverity fixes, Stefano Stabellini, 2023/04/12