Whamcloud - gitweb
LU-10657 utils: fd leak in mirror_split() 10/31410/2
authorBobi Jam <bobijam.xu@intel.com>
Sat, 24 Feb 2018 05:17:17 +0000 (13:17 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 3 Mar 2018 04:28:53 +0000 (04:28 +0000)
fd could be leaked in some error handling path for mirror_split().

Signed-off-by: Bobi Jam <bobijam.xu@intel.com>
Change-Id: I54b06191bd337ca7a9e6b58bdc4ab8197f29ed22
Reviewed-on: https://review.whamcloud.com/31410
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/utils/lfs.c

index fbddb03..d0ba643 100644 (file)
@@ -1742,7 +1742,7 @@ static int mirror_split(const char *fname, __u16 mirror_id,
                fprintf(stderr, "error %s: file name of '%s' too long\n",
                        progname, fname);
                rc = -ERANGE;
-               goto free_layout;
+               goto close_fd;
        }
        strncpy(parent, fname, sizeof(parent));
        ptr = strrchr(parent, '/');
@@ -1751,7 +1751,7 @@ static int mirror_split(const char *fname, __u16 mirror_id,
                        fprintf(stderr, "error %s: getcwd failed: %s\n",
                                progname, strerror(errno));
                        rc = -errno;
-                       goto free_layout;
+                       goto close_fd;
                }
        } else {
                if (ptr == parent)
@@ -1763,7 +1763,7 @@ static int mirror_split(const char *fname, __u16 mirror_id,
        if (rc < 0) {
                fprintf(stderr, "%s: cannot get MDT index of '%s'\n",
                        progname, fname);
-               goto free_layout;
+               goto close_fd;
        }
 
        if (victim_file == NULL) {