Skip to contentSkip to conversation

qtest/npcm7xx_pwm-test: Fix memory leak in mft_qom_set

PATCH In review Miaoqian Lin 2 participants 2 messages May 31, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qtest/npcm7xx_pwm-test: Fix memory leak in mft_qom_set

g_strdup_printf() allocated memory for path, we should free it with g_free() when no longer needed.

---
 tests/qtest/npcm7xx_pwm-test.c | 3 +++
 1 file changed, 3 insertions(+)
tests/qtest/npcm7xx_pwm-test.c +3 -0
index c4a5fdcacd79..e320a625c4b6 100644
@@ -268,6 +268,9 @@ static void mft_qom_set(QTestState *qts, int index, const char *name,
             path, name, value);
     /* The qom set message returns successfully. */
     g_assert_true(qdict_haskey(response, "return"));
+
+    qobject_unref(response);
+    g_free(path);
 }
 
 static uint32_t get_pll(uint32_t con)
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Miaoqian Lin

g_strdup_printf() allocated memory for path, we should free it with g_free() when no longer needed.

Quoted 25 lines
---
 tests/qtest/npcm7xx_pwm-test.c | 3 +++
 1 file changed, 3 insertions(+)
tests/qtest/npcm7xx_pwm-test.c +3 -0
index c4a5fdcacd79..e320a625c4b6 100644
@@ -268,6 +268,9 @@ static void mft_qom_set(QTestState *qts, int index,
 const char *name,
             path, name, value);
     /* The qom set message returns successfully. */
     g_assert_true(qdict_haskey(response, "return"));
+
+    qobject_unref(response);
+    g_free(path);
 }
 

static uint32_t get_pll(uint32_t con)
--
2.25.1