[PATCH 02/12] btrfs-progs: check fopen failure in cmds-send

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Check for fopen() failure.  This shows up in static analysis as a
possible null pointer derference.

Signed-off-by: Zach Brown <zab@xxxxxxxxxx>
---
 cmds-send.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/cmds-send.c b/cmds-send.c
index 374d040..5f6ff86 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -72,6 +72,11 @@ int find_mount_root(const char *path, char **mount_root)
 	close(fd);
 
 	mnttab = fopen("/proc/mounts", "r");
+	if (!mnttab) {
+		close(fd);
+		return -errno;
+	}
+
 	while ((ent = getmntent(mnttab))) {
 		len = strlen(ent->mnt_dir);
 		if (strncmp(ent->mnt_dir, path, len) == 0) {
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux