From: Darrick J. Wong Date: Thu, 12 Dec 2013 18:07:33 +0000 (-0500) Subject: e4defrag: don't crash if umounts the filesystem races with us X-Git-Tag: v1.42.9~75 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=e661d2815194d6db3f3e38223277569ad55bb420;p=thirdparty%2Fe2fsprogs.git 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" --- diff --git a/misc/e4defrag.c b/misc/e4defrag.c index 4b31d0362..b6e2e3195 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 {