Message ID | 1476164341-8636-2-git-send-email-xiecl.fnst@cn.fujitsu.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
diff --git a/block/replication.c b/block/replication.c index 3bd1cf1..5b432d9 100644 --- a/block/replication.c +++ b/block/replication.c @@ -104,11 +104,11 @@ static int replication_open(BlockDriverState *bs, QDict *options, } else if (!strcmp(mode, "secondary")) { s->mode = REPLICATION_MODE_SECONDARY; top_id = qemu_opt_get(opts, REPLICATION_TOP_ID); - s->top_id = g_strdup(top_id); - if (!s->top_id) { + if (!top_id) { error_setg(&local_err, "Missing the option top-id"); goto fail; } + s->top_id = g_strdup(top_id); } else { error_setg(&local_err, "The option mode's value should be primary or secondary");
Only g_strdup(top_id) if 'top_id' is not NULL, although there is no memory leak here Signed-off-by: Changlong Xie <xiecl.fnst@cn.fujitsu.com> --- block/replication.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)