From e661d2815194d6db3f3e38223277569ad55bb420 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Thu, 12 Dec 2013 13:07:33 -0500 Subject: [PATCH] e4defrag: don't crash if umounts the filesystem races with us If someone umounts the filesystem between statfs64() and the getmntent() iteration, we can exit the loop having never set mnt_type, and strcmp can crash. Fix the potential NULL dereference. Signed-off-by: Darrick J. Wong Signed-off-by: "Theodore Ts'o" --- misc/e4defrag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/e4defrag.c b/misc/e4defrag.c index 4b31d03..b6e2e31 100644 --- a/misc/e4defrag.c +++ b/misc/e4defrag.c @@ -374,7 +374,7 @@ static int is_ext4(const char *file, char *devname) } endmntent(fp); - if (strcmp(mnt_type, FS_EXT4) == 0) { + if (mnt_type && strcmp(mnt_type, FS_EXT4) == 0) { FREE(mnt_type); return 0; } else { -- 1.8.3.1