diff options
author | Mel Gorman <mgorman@suse.de> | 2012-12-05 17:01:41 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-06 14:56:43 -0500 |
commit | 18a2f371f5edf41810f6469cb9be39931ef9deb9 (patch) | |
tree | 4e4ec26f13273b36fc7203d2084ea09f14c5f0f7 /include | |
parent | c702418f8a2fa6cc92e84a39880d458faf7af9cc (diff) |
tmpfs: fix shared mempolicy leak
This fixes a regression in 3.7-rc, which has since gone into stable.
Commit 00442ad04a5e ("mempolicy: fix a memory corruption by refcount
imbalance in alloc_pages_vma()") changed get_vma_policy() to raise the
refcount on a shmem shared mempolicy; whereas shmem_alloc_page() went
on expecting alloc_page_vma() to drop the refcount it had acquired.
This deserves a rework: but for now fix the leak in shmem_alloc_page().
Hugh: shmem_swapin() did not need a fix, but surely it's clearer to use
the same refcounting there as in shmem_alloc_page(), delete its onstack
mempolicy, and the strange mpol_cond_copy() and __mpol_cond_copy() -
those were invented to let swapin_readahead() make an unknown number of
calls to alloc_pages_vma() with one mempolicy; but since 00442ad04a5e,
alloc_pages_vma() has kept refcount in balance, so now no problem.
Reported-and-tested-by: Tommi Rantala <tt.rantala@gmail.com>
Signed-off-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/mempolicy.h | 16 |
1 files changed, 0 insertions, 16 deletions
diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h index e5ccb9ddd90e..dbd212723b74 100644 --- a/include/linux/mempolicy.h +++ b/include/linux/mempolicy.h | |||
@@ -82,16 +82,6 @@ static inline void mpol_cond_put(struct mempolicy *pol) | |||
82 | __mpol_put(pol); | 82 | __mpol_put(pol); |
83 | } | 83 | } |
84 | 84 | ||
85 | extern struct mempolicy *__mpol_cond_copy(struct mempolicy *tompol, | ||
86 | struct mempolicy *frompol); | ||
87 | static inline struct mempolicy *mpol_cond_copy(struct mempolicy *tompol, | ||
88 | struct mempolicy *frompol) | ||
89 | { | ||
90 | if (!frompol) | ||
91 | return frompol; | ||
92 | return __mpol_cond_copy(tompol, frompol); | ||
93 | } | ||
94 | |||
95 | extern struct mempolicy *__mpol_dup(struct mempolicy *pol); | 85 | extern struct mempolicy *__mpol_dup(struct mempolicy *pol); |
96 | static inline struct mempolicy *mpol_dup(struct mempolicy *pol) | 86 | static inline struct mempolicy *mpol_dup(struct mempolicy *pol) |
97 | { | 87 | { |
@@ -215,12 +205,6 @@ static inline void mpol_cond_put(struct mempolicy *pol) | |||
215 | { | 205 | { |
216 | } | 206 | } |
217 | 207 | ||
218 | static inline struct mempolicy *mpol_cond_copy(struct mempolicy *to, | ||
219 | struct mempolicy *from) | ||
220 | { | ||
221 | return from; | ||
222 | } | ||
223 | |||
224 | static inline void mpol_get(struct mempolicy *pol) | 208 | static inline void mpol_get(struct mempolicy *pol) |
225 | { | 209 | { |
226 | } | 210 | } |