mempolicy: fix refcount leak in mpol_set_shared_policy()
authorKOSAKI Motohiro <[email protected]>
Mon, 8 Oct 2012 23:29:19 +0000 (16:29 -0700)
committerLinus Torvalds <[email protected]>
Tue, 9 Oct 2012 07:22:22 +0000 (16:22 +0900)
commit63f74ca21f1fad36d075e063f06dcc6d39fe86b2
tree44ba87965b18f77fbb464d891ef07b2eca8304d4
parentb22d127a39ddd10d93deee3d96e643657ad53a49
mempolicy: fix refcount leak in mpol_set_shared_policy()

When shared_policy_replace() fails to allocate new->policy is not freed
correctly by mpol_set_shared_policy().  The problem is that shared
mempolicy code directly call kmem_cache_free() in multiple places where
it is easy to make a mistake.

This patch creates an sp_free wrapper function and uses it. The bug was
introduced pre-git age (IOW, before 2.6.12-rc2).

[[email protected]: Editted changelog]
Signed-off-by: KOSAKI Motohiro <[email protected]>
Signed-off-by: Mel Gorman <[email protected]>
Reviewed-by: Christoph Lameter <[email protected]>
Cc: Josh Boyer <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/mempolicy.c