Whamcloud - gitweb
LU-12641 libext2fs: memory leak of check_if_lustre_mounted 29/35729/4
authorLi Xi <lixi@ddn.com>
Thu, 8 Aug 2019 08:59:59 +0000 (16:59 +0800)
committerAndreas Dilger <adilger@whamcloud.com>
Thu, 24 Sep 2020 07:33:04 +0000 (07:33 +0000)
check_if_lustre_mounted() doesn't free the allocated memory
if failure.

Change-Id: I36b5c1e981ca4f1db8c9515be29dd98c074d14dc
Signed-off-by: Li Xi <lixi@ddn.com>
Reviewed-on: https://review.whamcloud.com/35729
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Wang Shilong <wshilong@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lib/ext2fs/ismounted.c

index 0d7c5e2..0a78497 100644 (file)
@@ -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;
 }