From: Li Xi Date: Thu, 8 Aug 2019 08:59:59 +0000 (+0800) Subject: LU-12641 libext2fs: memory leak of check_if_lustre_mounted X-Git-Tag: v1.45.6.wc2~60 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F29%2F35729%2F4;p=tools%2Fe2fsprogs.git LU-12641 libext2fs: memory leak of check_if_lustre_mounted check_if_lustre_mounted() doesn't free the allocated memory if failure. Change-Id: I36b5c1e981ca4f1db8c9515be29dd98c074d14dc Signed-off-by: Li Xi Reviewed-on: https://review.whamcloud.com/35729 Reviewed-by: Andreas Dilger Tested-by: jenkins Reviewed-by: Wang Shilong Tested-by: Maloo --- diff --git a/lib/ext2fs/ismounted.c b/lib/ext2fs/ismounted.c index 0d7c5e2..0a78497 100644 --- a/lib/ext2fs/ismounted.c +++ b/lib/ext2fs/ismounted.c @@ -510,7 +510,8 @@ static errcode_t check_if_lustre_mounted(const char *device, int *mount_flags) if (realpath(device, real_device) == NULL) { fprintf(stderr, "Cannot resolve path %s\n", device); - return EXT2_ET_BAD_DEVICE_NAME; + rc = EXT2_ET_BAD_DEVICE_NAME; + goto out_free; } rc = check_lustre_proc_vals("/proc/fs/lustre/osd-ldiskfs", real_device); @@ -520,9 +521,10 @@ static errcode_t check_if_lustre_mounted(const char *device, int *mount_flags) if (rc) *mount_flags |= EXT2_MF_MOUNTED; +out_free: free(real_device); - return 0; + return rc; }