[PATCH 6/8] xfs_fsr: check strdup results properly in initallfs()

Eric Sandeen sandeen at redhat.com
Sat Jan 26 16:40:30 CST 2013


initallfs() does 2 strdups, but then checks the result
of one of them twice, rather then checking each one.
Fix this.

Signed-off-by: Eric Sandeen <sandeen at redhat.com>
---
 fsr/xfs_fsr.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
index 843f57d..b5aa3db 100644
--- a/fsr/xfs_fsr.c
+++ b/fsr/xfs_fsr.c
@@ -470,10 +470,14 @@ initallfs(char *mtab)
 		fs->dev = strdup(mp->mnt_fsname);
 		fs->mnt = strdup(mp->mnt_dir);
 
-		if (fs->mnt == NULL || fs->mnt == NULL) {
+		if (fs->dev == NULL) {
 			fsrprintf(_("strdup(%s) failed\n"), mp->mnt_fsname);
 			exit(1);
 		}
+		if (fs->mnt == NULL) {
+			fsrprintf(_("strdup(%s) failed\n"), mp->mnt_dir);
+			exit(1);
+		}
 		mi++;
 		fs++;
 	}
-- 
1.7.1



More information about the xfs mailing list