]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
hugetlb: fix resv_map leak in error path
authorDave Hansen <dave@linux.vnet.ibm.com>
Fri, 18 May 2012 18:46:30 +0000 (11:46 -0700)
committerBen Hutchings <ben@decadent.org.uk>
Sun, 10 Jun 2012 13:41:45 +0000 (14:41 +0100)
commit73436db332d5b4dd792f115cf0b500521badf3e5
treef411e9ff2591f9de33ab0a06bdadfc9c6bea782f
parentd006ab31cd818f5e4dda2453fd09767063f49933
hugetlb: fix resv_map leak in error path

commit c50ac050811d6485616a193eb0f37bfbd191cc89 upstream.

When called for anonymous (non-shared) mappings, hugetlb_reserve_pages()
does a resv_map_alloc().  It depends on code in hugetlbfs's
vm_ops->close() to release that allocation.

However, in the mmap() failure path, we do a plain unmap_region() without
the remove_vma() which actually calls vm_ops->close().

This is a decent fix.  This leak could get reintroduced if new code (say,
after hugetlb_reserve_pages() in hugetlbfs_file_mmap()) decides to return
an error.  But, I think it would have to unroll the reservation anyway.

Christoph's test case:

http://marc.info/?l=linux-mm&m=133728900729735

Signed-off-by: Dave Hansen <dave@linux.vnet.ibm.com>
[Christoph Lameter: I have rediffed the patch against 2.6.32 and 3.2.0.]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
mm/hugetlb.c