aboutsummaryrefslogtreecommitdiffstats
path: root/mm/util.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2009-11-30 20:12:03 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2009-12-11 06:44:57 -0500
commit8c7b49b3ecd48923eb64ff57e07a1cdb74782970 (patch)
tree3bb2335ccaa34ef227459800c2221e71cf6b1987 /mm/util.c
parentf8b7256096a20436f6d0926747e3ac3d64c81d24 (diff)
fix a struct file leak in do_mmap_pgoff()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'mm/util.c')
-rw-r--r--mm/util.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/mm/util.c b/mm/util.c
index 3bf81b294ae8..b377ce430803 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -280,9 +280,24 @@ SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len,
280 unsigned long retval = -EBADF; 280 unsigned long retval = -EBADF;
281 281
282 if (!(flags & MAP_ANONYMOUS)) { 282 if (!(flags & MAP_ANONYMOUS)) {
283 if (unlikely(flags & MAP_HUGETLB))
284 return -EINVAL;
283 file = fget(fd); 285 file = fget(fd);
284 if (!file) 286 if (!file)
285 goto out; 287 goto out;
288 } else if (flags & MAP_HUGETLB) {
289 struct user_struct *user = NULL;
290 /*
291 * VM_NORESERVE is used because the reservations will be
292 * taken when vm_ops->mmap() is called
293 * A dummy user value is used because we are not locking
294 * memory so no accounting is necessary
295 */
296 len = ALIGN(len, huge_page_size(&default_hstate));
297 file = hugetlb_file_setup(HUGETLB_ANON_FILE, len, VM_NORESERVE,
298 &user, HUGETLB_ANONHUGE_INODE);
299 if (IS_ERR(file))
300 return PTR_ERR(file);
286 } 301 }
287 302
288 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); 303 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);