summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2014-05-28 11:17:06 +0200
committerKevin Wolf <kwolf@redhat.com>2014-05-30 14:26:54 +0200
commit2df5fee2dbd56a9c34afd6d7df6744da2d951ccb (patch)
tree0a2a9caa9afc45260b8f7c037a64976e920743fb
parentb122c3b6d020e529b203836efb8f611ece787293 (diff)
block/sheepdog: Plug memory leak in sd_snapshot_create()
Has always been leaky. Spotted by Coverity. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Benoit Canet <benoit@irqsave.net> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r--block/sheepdog.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/block/sheepdog.c b/block/sheepdog.c
index 39f746157a..4ecbf5f498 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -2176,6 +2176,7 @@ static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
strncpy(s->inode.tag, sn_info->name, sizeof(s->inode.tag));
/* we don't need to update entire object */
datalen = SD_INODE_SIZE - sizeof(s->inode.data_vdi_id);
+ inode = g_malloc(datalen);
/* refresh inode. */
fd = connect_to_sdog(s, &local_err);
@@ -2202,8 +2203,6 @@ static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
goto cleanup;
}
- inode = (SheepdogInode *)g_malloc(datalen);
-
ret = read_object(fd, (char *)inode, vid_to_vdi_oid(new_vid),
s->inode.nr_copies, datalen, 0, s->cache_flags);
@@ -2217,6 +2216,7 @@ static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
s->inode.name, s->inode.snap_id, s->inode.vdi_id);
cleanup:
+ g_free(inode);
closesocket(fd);
return ret;
}