computing-offload/generic_vdpa/libvirt/locking-Resolve-mem-leak-in-virLockDaemonPreExecRest.patch
jiangdongxu 79c4324644 add generic_vdpa basecode
Change-Id: I2d302dda68298877c65c99147f5bf22186a59aac
2024-09-19 17:19:46 +08:00

57 lines
1.8 KiB
Diff

From 3542d88e097199e80419ebcb1a82b68cc71d3e2b Mon Sep 17 00:00:00 2001
From: John Ferlan <jferlan@redhat.com>
Date: Wed, 2 Dec 2020 07:43:20 -0500
Subject: [PATCH 021/108] locking: Resolve mem leak in
virLockDaemonPreExecRestart
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Initialize and free @magic since virJSONValueObjectAppendString
does not free it for us eventually.
Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 6f0418173b5567d17dba43247efc058f0318485b)
---
src/locking/lock_daemon.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index 3d33995beb..9bf505c939 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -722,7 +722,7 @@ virLockDaemonPreExecRestart(const char *state_file,
char *state = NULL;
int ret = -1;
virJSONValuePtr object = virJSONValueNewObject();
- char *magic;
+ char *magic = NULL;
virHashKeyValuePairPtr pairs = NULL, tmp;
virJSONValuePtr lockspaces;
@@ -770,10 +770,8 @@ virLockDaemonPreExecRestart(const char *state_file,
if (!(magic = virLockDaemonGetExecRestartMagic()))
goto cleanup;
- if (virJSONValueObjectAppendString(object, "magic", magic) < 0) {
- VIR_FREE(magic);
+ if (virJSONValueObjectAppendString(object, "magic", magic) < 0)
goto cleanup;
- }
if (!(state = virJSONValueToString(object, true)))
goto cleanup;
@@ -797,6 +795,7 @@ virLockDaemonPreExecRestart(const char *state_file,
abort(); /* This should be impossible to reach */
cleanup:
+ VIR_FREE(magic);
VIR_FREE(pairs);
VIR_FREE(state);
virJSONValueFree(object);
--
2.33.0