btrfs-progs: check fopen failure in cmds-send
authorZach Brown <zab@redhat.com>
Fri, 11 Oct 2013 16:21:46 +0000 (09:21 -0700)
committerChris Mason <chris.mason@fusionio.com>
Wed, 16 Oct 2013 12:23:13 +0000 (08:23 -0400)
Check for fopen() failure.  This shows up in static analysis as a
possible null pointer derference.

Signed-off-by: Zach Brown <zab@redhat.com>
Laughed-at-by: Stefan Behrens <sbehrens@giantdisaster.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
cmds-send.c

index 374d040..81b3e49 100644 (file)
@@ -72,6 +72,9 @@ int find_mount_root(const char *path, char **mount_root)
        close(fd);
 
        mnttab = fopen("/proc/mounts", "r");
+       if (!mnttab)
+               return -errno;
+
        while ((ent = getmntent(mnttab))) {
                len = strlen(ent->mnt_dir);
                if (strncmp(ent->mnt_dir, path, len) == 0) {