yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-sheepdog-Fix-sd_co_create_opts-memory-leaks.patch

ae23c9
From de0616c738537b21828f572c6c679ad4b290b81e Mon Sep 17 00:00:00 2001
ae23c9
From: Kevin Wolf <kwolf@redhat.com>
ae23c9
Date: Tue, 26 Jun 2018 09:47:44 +0200
ae23c9
Subject: [PATCH 076/268] sheepdog: Fix sd_co_create_opts() memory leaks
ae23c9
ae23c9
RH-Author: Kevin Wolf <kwolf@redhat.com>
ae23c9
Message-id: <20180626094856.6924-2-kwolf@redhat.com>
ae23c9
Patchwork-id: 81074
ae23c9
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH v2 01/73] sheepdog: Fix sd_co_create_opts() memory leaks
ae23c9
Bugzilla: 1513543
ae23c9
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
ae23c9
RH-Acked-by: Max Reitz <mreitz@redhat.com>
ae23c9
RH-Acked-by: Fam Zheng <famz@redhat.com>
ae23c9
ae23c9
Both the option string for the 'redundancy' option and the
ae23c9
SheepdogRedundancy object that is created accordingly could be leaked in
ae23c9
error paths. This fixes the memory leaks.
ae23c9
ae23c9
Reported by Coverity (CID 1390614 and 1390641).
ae23c9
ae23c9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
Message-id: 20180503153509.22223-1-kwolf@redhat.com
ae23c9
Reviewed-by: Jeff Cody <jcody@redhat.com>
ae23c9
Signed-off-by: Jeff Cody <jcody@redhat.com>
ae23c9
(cherry picked from commit a2cb9239b7610ffb00f9ced5cd7640d40b0e1ccf)
ae23c9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ae23c9
---
ae23c9
 block/sheepdog.c | 4 +++-
ae23c9
 1 file changed, 3 insertions(+), 1 deletion(-)
ae23c9
ae23c9
diff --git a/block/sheepdog.c b/block/sheepdog.c
ae23c9
index d1c9bf5..933880c 100644
ae23c9
--- a/block/sheepdog.c
ae23c9
+++ b/block/sheepdog.c
ae23c9
@@ -1977,6 +1977,7 @@ static SheepdogRedundancy *parse_redundancy_str(const char *opt)
ae23c9
     } else {
ae23c9
         ret = qemu_strtol(n2, NULL, 10, &parity);
ae23c9
         if (ret < 0) {
ae23c9
+            g_free(redundancy);
ae23c9
             return NULL;
ae23c9
         }
ae23c9
 
ae23c9
@@ -2172,7 +2173,7 @@ static int coroutine_fn sd_co_create_opts(const char *filename, QemuOpts *opts,
ae23c9
     BlockdevCreateOptions *create_options = NULL;
ae23c9
     QDict *qdict, *location_qdict;
ae23c9
     Visitor *v;
ae23c9
-    const char *redundancy;
ae23c9
+    char *redundancy;
ae23c9
     Error *local_err = NULL;
ae23c9
     int ret;
ae23c9
 
ae23c9
@@ -2240,6 +2241,7 @@ static int coroutine_fn sd_co_create_opts(const char *filename, QemuOpts *opts,
ae23c9
 fail:
ae23c9
     qapi_free_BlockdevCreateOptions(create_options);
ae23c9
     qobject_unref(qdict);
ae23c9
+    g_free(redundancy);
ae23c9
     return ret;
ae23c9
 }
ae23c9
 
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9