* [PATCH] mempolicy: fix dangling reference to tmpfs superblock mpol
@ 2010-06-15 17:47 Lee Schermerhorn
2010-06-15 19:11 ` Dan Carpenter
0 siblings, 1 reply; 2+ messages in thread
From: Lee Schermerhorn @ 2010-06-15 17:47 UTC (permalink / raw)
To: Andrew Morton, linux-kernel
Cc: Dan Carpenter, KOSAKI Motohiro, David Rientjes, Christoph Lameter
Against 2.6.35-rc1+
My patch to "Factor out duplicate put/frees in mpol_shared_policy_init()
to a common return path"; and Dan Carpenter's fix thereto both left a
dangling reference to the incoming tmpfs superblock mempolicy structure.
A similar leak was introduced earlier when the nodemask was moved offstack
to the scratch area despite the note in the comment block regarding the
incoming ref.
Move the remaining 'put of the incoming "mpol" to the common exit path to
drop the reference.
Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com>
mm/mempolicy.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
Index: linux-2.6.35-rc2-mmotm-100611-1640/mm/mempolicy.c
===================================================================
--- linux-2.6.35-rc2-mmotm-100611-1640.orig/mm/mempolicy.c
+++ linux-2.6.35-rc2-mmotm-100611-1640/mm/mempolicy.c
@@ -2138,7 +2138,7 @@ void mpol_shared_policy_init(struct shar
NODEMASK_SCRATCH(scratch);
if (!scratch)
- return;
+ goto put_mpol;
/* contextualize the tmpfs mount point mempolicy */
new = mpol_new(mpol->mode, mpol->flags, &mpol->w.user_nodemask);
if (IS_ERR(new))
@@ -2147,19 +2147,20 @@ void mpol_shared_policy_init(struct shar
task_lock(current);
ret = mpol_set_nodemask(new, &mpol->w.user_nodemask, scratch);
task_unlock(current);
- mpol_put(mpol); /* drop our ref on sb mpol */
if (ret)
- goto put_free;
+ goto put_new;
/* Create pseudo-vma that contains just the policy */
memset(&pvma, 0, sizeof(struct vm_area_struct));
pvma.vm_end = TASK_SIZE; /* policy covers entire file */
mpol_set_shared_policy(sp, &pvma, new); /* adds ref */
-put_free:
+put_new:
mpol_put(new); /* drop initial ref */
free_scratch:
NODEMASK_SCRATCH_FREE(scratch);
+put_mpol:
+ mpol_put(mpol); /* drop our incoming ref on sb mpol */
}
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] mempolicy: fix dangling reference to tmpfs superblock mpol
2010-06-15 17:47 [PATCH] mempolicy: fix dangling reference to tmpfs superblock mpol Lee Schermerhorn
@ 2010-06-15 19:11 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2010-06-15 19:11 UTC (permalink / raw)
To: Lee Schermerhorn
Cc: Andrew Morton, linux-kernel, KOSAKI Motohiro, David Rientjes,
Christoph Lameter
On Tue, Jun 15, 2010 at 01:47:17PM -0400, Lee Schermerhorn wrote:
> Against 2.6.35-rc1+
>
> My patch to "Factor out duplicate put/frees in mpol_shared_policy_init()
> to a common return path"; and Dan Carpenter's fix thereto both left a
> dangling reference to the incoming tmpfs superblock mempolicy structure.
> A similar leak was introduced earlier when the nodemask was moved offstack
> to the scratch area despite the note in the comment block regarding the
> incoming ref.
>
Yup. You're right.
Acked-by: Dan Carpenter <error27@gmail.com>
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-06-15 19:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-15 17:47 [PATCH] mempolicy: fix dangling reference to tmpfs superblock mpol Lee Schermerhorn
2010-06-15 19:11 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox