summaryrefslogtreecommitdiff
path: root/cmds-send.c
diff options
context:
space:
mode:
authorZach Brown <zab@redhat.com>2013-10-11 09:21:46 -0700
committerChris Mason <chris.mason@fusionio.com>2013-10-16 08:23:13 -0400
commit3fed284f931a60d58d7896c6e1d9d2d0b22da6c1 (patch)
treed8b12b86ab1e0dc855b9bc220c9bcc25baef5747 /cmds-send.c
parentf539dbb3e50f2fd2b6a35a5a670b32569c9eb994 (diff)
btrfs-progs: check fopen failure in cmds-send
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>
Diffstat (limited to 'cmds-send.c')
-rw-r--r--cmds-send.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/cmds-send.c b/cmds-send.c
index 374d0403..81b3e496 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -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) {