Whamcloud - gitweb
LU-2281 utils: Fix possible segfault in tunefs.lustre
authorNathaniel Clark <nathaniel.l.clark@intel.com>
Mon, 5 Nov 2012 21:22:33 +0000 (16:22 -0500)
committerOleg Drokin <green@whamcloud.com>
Wed, 7 Nov 2012 02:54:35 +0000 (21:54 -0500)
ldiskfs_read_ldd() can segfault if fopen of mountdata fails, because
it will always try to fclose the file handled (which if it is NULL,
dies).

Signed-off-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Change-Id: I553a7972b61ec01473bf834f98f8937bc7b11dbc
Reviewed-on: http://review.whamcloud.com/4470
Tested-by: Hudson
Reviewed-by: Niu Yawei <niu@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/utils/mount_utils_ldiskfs.c

index c6e6e8c..fe365e8 100644 (file)
@@ -219,11 +219,9 @@ int ldiskfs_read_ldd(char *dev, struct lustre_disk_data *mo_ldd)
                if (num_read < 1 && ferror(filep)) {
                        fprintf(stderr, "%s: Unable to read from file %s: %s\n",
                                progname, filepnm, strerror(errno));
-                       goto out_close;
                }
+               fclose(filep);
        }
-out_close:
-       fclose(filep);
 
        snprintf(cmd, cmdsz, "rm -rf %s", tmpdir);
        run_command(cmd, cmdsz);