summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfork0@users.sf.net <fork0@users.sf.net>2004-06-08 16:47:16 -0700
committerGreg KH <gregkh@suse.de>2005-04-26 21:35:47 -0700
commit686cecf24216770190133aa6f270bb2b124329a7 (patch)
tree54963a7256d52d017041c12a9ecfc6ae0f09424a
parente3496f5932ab1460519db5c789bf6fdb242dd4c5 (diff)
[PATCH] fix handle leak in udev_lib.c
There is a handle leak in failure path in file_map, and the result of file_map (or the result of the caller of the file_map) is not always checked.
-rw-r--r--udev_lib.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/udev_lib.c b/udev_lib.c
index 16b473f576..8f6aa42377 100644
--- a/udev_lib.c
+++ b/udev_lib.c
@@ -124,11 +124,13 @@ int file_map(const char *filename, char **buf, size_t *bufsize)
}
if (fstat(fd, &stats) < 0) {
+ close(fd);
return -1;
}
*buf = mmap(NULL, stats.st_size, PROT_READ, MAP_SHARED, fd, 0);
if (*buf == MAP_FAILED) {
+ close(fd);
return -1;
}
*bufsize = stats.st_size;