All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] migration/options: Fix leaks in StrOrNull accessors
@ 2026-01-22 23:24 Fabiano Rosas
  2026-01-23 10:08 ` Prasad Pandit
  2026-01-26 16:27 ` Peter Xu
  0 siblings, 2 replies; 8+ messages in thread
From: Fabiano Rosas @ 2026-01-22 23:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: peterx, armbru, Peter Maydell

Fix a couple of leaks detected by Coverity. Both are currently
harmless because the visitor in the setter can never fail and the
whole of the getter is unused, it's only purpose at the moment is to
provide a complete implementation of the StrOrNull property.

Fixes: CID 1643919
Fixes: CID 1643920
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
CI run: https://gitlab.com/farosas/qemu/-/pipelines/2280325023
---
 migration/options.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/migration/options.c b/migration/options.c
index 9a5a39c886..9dc44a3736 100644
--- a/migration/options.c
+++ b/migration/options.c
@@ -225,6 +225,7 @@ static void get_StrOrNull(Object *obj, Visitor *v, const char *name,
         str_or_null = g_new0(StrOrNull, 1);
         str_or_null->type = QTYPE_QSTRING;
         str_or_null->u.s = g_strdup("");
+        *ptr = str_or_null;
     } else {
         /* the setter doesn't allow QNULL */
         assert(str_or_null->type != QTYPE_QNULL);
@@ -245,6 +246,7 @@ static void set_StrOrNull(Object *obj, Visitor *v, const char *name,
      */
     str_or_null->type = QTYPE_QSTRING;
     if (!visit_type_str(v, name, &str_or_null->u.s, errp)) {
+        qapi_free_StrOrNull(str_or_null);
         return;
     }
 
-- 
2.51.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-01-26 19:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-22 23:24 [PATCH] migration/options: Fix leaks in StrOrNull accessors Fabiano Rosas
2026-01-23 10:08 ` Prasad Pandit
2026-01-23 12:21   ` Fabiano Rosas
2026-01-23 12:37     ` Prasad Pandit
2026-01-23 13:15       ` Fabiano Rosas
2026-01-26 16:27 ` Peter Xu
2026-01-26 19:16   ` Fabiano Rosas
2026-01-26 19:57     ` Peter Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.