[sheepdog] [PATCH v1 1/2] dog: memory leak in vdi_object_map
Hitoshi Mitake
mitake.hitoshi at gmail.com
Wed Jul 23 15:43:16 CEST 2014
At Wed, 23 Jul 2014 12:39:33 +0800,
Meng An wrote:
>
> From: meng an <isolate000 at gmail.com>
>
> In function vdi_object_map, the pointer 'inode' is allocated via
> xmalloc, but its memory is not released when returns.
>
> Signed-off-by: Meng An <anmeng.an at alibaba-inc.com>
> ---
> dog/vdi.c | 10 ++++++----
> 1 files changed, 6 insertions(+), 4 deletions(-)
Applied, thanks.
Hitoshi
>
> diff --git a/dog/vdi.c b/dog/vdi.c
> index 9fc1677..30739ff 100644
> --- a/dog/vdi.c
> +++ b/dog/vdi.c
> @@ -864,15 +864,14 @@ static int vdi_object_map(int argc, char **argv)
> uint64_t idx = vdi_cmd_data.index;
> struct sd_inode *inode = xmalloc(sizeof(*inode));
> uint32_t vid;
> - int ret;
> + int ret = EXIT_SUCCESS;
>
> ret = read_vdi_obj(vdiname, vdi_cmd_data.snapshot_id,
> vdi_cmd_data.snapshot_tag, NULL, inode,
> SD_INODE_SIZE);
> if (ret != EXIT_SUCCESS) {
> sd_err("FATAL: %s not found", vdiname);
> - free(inode);
> - return ret;
> + goto out;
> }
>
> printf("Index VID\n");
> @@ -888,7 +887,10 @@ static int vdi_object_map(int argc, char **argv)
> printf("%08"PRIu64" %8"PRIx32"\n", idx, vid);
> }
> }
> - return EXIT_SUCCESS;
> +
> +out:
> + free(inode);
> + return ret;
> }
>
> static void print_expected_location(uint64_t oid, int copies)
> --
> 1.7.1
>
> --
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog
More information about the sheepdog
mailing list