xfs
[Top] [All Lists]

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

To: xfs@xxxxxxxxxxx
Subject: [PATCH 6/8] xfs_fsr: check strdup results properly in initallfs()
From: Eric Sandeen <sandeen@xxxxxxxxxx>
Date: Sat, 26 Jan 2013 16:40:30 -0600
Cc: Eric Sandeen <sandeen@xxxxxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1359240032-11576-1-git-send-email-sandeen@xxxxxxxxxx>
References: <1359240032-11576-1-git-send-email-sandeen@xxxxxxxxxx>
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@xxxxxxxxxx>
---
 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

<Prev in Thread] Current Thread [Next in Thread>