Commit a2cb9239 authored by Kevin Wolf's avatar Kevin Wolf Committed by Jeff Cody
Browse files

sheepdog: Fix sd_co_create_opts() memory leaks



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: default avatarKevin Wolf <kwolf@redhat.com>
Message-id: 20180503153509.22223-1-kwolf@redhat.com
Reviewed-by: default avatarJeff Cody <jcody@redhat.com>
Signed-off-by: default avatarJeff Cody <jcody@redhat.com>
parent dc885fff
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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;
}