Commit 15d77835ac48dbc2d4884376ea6a08b65b1c40ba
Committed by
Linus Torvalds
1 parent
345ace9c79
Exists in
master
and in
20 other branches
mempolicy: factor mpol_shared_policy_init() return paths
Factor out duplicate put/frees in mpol_shared_policy_init() to a common return path. Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com> Cc: Hugh Dickins <hugh.dickins@tiscali.co.uk> Cc: Ravikiran Thirumalai <kiran@scalex86.org> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: Christoph Lameter <cl@linux-foundation.org> Cc: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 6 additions and 10 deletions Side-by-side Diff
mm/mempolicy.c
... | ... | @@ -1995,26 +1995,22 @@ |
1995 | 1995 | return; |
1996 | 1996 | /* contextualize the tmpfs mount point mempolicy */ |
1997 | 1997 | new = mpol_new(mpol->mode, mpol->flags, &mpol->w.user_nodemask); |
1998 | - if (IS_ERR(new)) { | |
1999 | - mpol_put(mpol); /* drop our ref on sb mpol */ | |
2000 | - NODEMASK_SCRATCH_FREE(scratch); | |
2001 | - return; /* no valid nodemask intersection */ | |
2002 | - } | |
1998 | + if (IS_ERR(new)) | |
1999 | + goto put_free; /* no valid nodemask intersection */ | |
2003 | 2000 | |
2004 | 2001 | task_lock(current); |
2005 | 2002 | ret = mpol_set_nodemask(new, &mpol->w.user_nodemask, scratch); |
2006 | 2003 | task_unlock(current); |
2007 | 2004 | mpol_put(mpol); /* drop our ref on sb mpol */ |
2008 | - if (ret) { | |
2009 | - NODEMASK_SCRATCH_FREE(scratch); | |
2010 | - mpol_put(new); | |
2011 | - return; | |
2012 | - } | |
2005 | + if (ret) | |
2006 | + goto put_free; | |
2013 | 2007 | |
2014 | 2008 | /* Create pseudo-vma that contains just the policy */ |
2015 | 2009 | memset(&pvma, 0, sizeof(struct vm_area_struct)); |
2016 | 2010 | pvma.vm_end = TASK_SIZE; /* policy covers entire file */ |
2017 | 2011 | mpol_set_shared_policy(sp, &pvma, new); /* adds ref */ |
2012 | + | |
2013 | +put_free: | |
2018 | 2014 | mpol_put(new); /* drop initial ref */ |
2019 | 2015 | NODEMASK_SCRATCH_FREE(scratch); |
2020 | 2016 | } |