From 32ad9cdf2e99eff52b9241c1f306c45eb19acc62 Mon Sep 17 00:00:00 2001 From: Nathaniel Clark Date: Mon, 5 Nov 2012 16:22:33 -0500 Subject: [PATCH] LU-2281 utils: Fix possible segfault in tunefs.lustre 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 Change-Id: I553a7972b61ec01473bf834f98f8937bc7b11dbc Reviewed-on: http://review.whamcloud.com/4470 Tested-by: Hudson Reviewed-by: Niu Yawei Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin --- lustre/utils/mount_utils_ldiskfs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lustre/utils/mount_utils_ldiskfs.c b/lustre/utils/mount_utils_ldiskfs.c index c6e6e8c..fe365e8 100644 --- a/lustre/utils/mount_utils_ldiskfs.c +++ b/lustre/utils/mount_utils_ldiskfs.c @@ -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); -- 1.8.3.1