]> Git Repo - qemu.git/commitdiff
sheepdog: Fix sd_co_create_opts() memory leaks
authorKevin Wolf <[email protected]>
Thu, 3 May 2018 15:35:09 +0000 (17:35 +0200)
committerJeff Cody <[email protected]>
Tue, 8 May 2018 14:47:27 +0000 (10:47 -0400)
Both the option string for the 'redundancy' option and the
SheepdogRedundancy object that is created accordingly could be leaked in
error paths. This fixes the memory leaks.

Reported by Coverity (CID 1390614 and 1390641).

Signed-off-by: Kevin Wolf <[email protected]>
Message-id: 20180503153509[email protected]
Reviewed-by: Jeff Cody <[email protected]>
Signed-off-by: Jeff Cody <[email protected]>
block/sheepdog.c

index 07529f4b1bd1592371487ab330edf7c44ad7faaf..fed2a04797236138e200dbc010cee23b5b89205f 100644 (file)
@@ -1987,6 +1987,7 @@ static SheepdogRedundancy *parse_redundancy_str(const char *opt)
     } else {
         ret = qemu_strtol(n2, NULL, 10, &parity);
         if (ret < 0) {
+            g_free(redundancy);
             return NULL;
         }
 
@@ -2183,7 +2184,7 @@ static int coroutine_fn sd_co_create_opts(const char *filename, QemuOpts *opts,
     QDict *qdict, *location_qdict;
     QObject *crumpled;
     Visitor *v;
-    const char *redundancy;
+    char *redundancy;
     Error *local_err = NULL;
     int ret;
 
@@ -2253,6 +2254,7 @@ static int coroutine_fn sd_co_create_opts(const char *filename, QemuOpts *opts,
 fail:
     qapi_free_BlockdevCreateOptions(create_options);
     qobject_unref(qdict);
+    g_free(redundancy);
     return ret;
 }
 
This page took 0.028137 seconds and 4 git commands to generate.