The patch titled Subject: mm/mempolicy: fix exception handling in shared_policy_replace() has been added to the -mm mm-unstable branch. Its filename is mm-mempolicy-fix-exception-handling-in-shared_policy_replace.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-mempolicy-fix-exception-handling-in-shared_policy_replace.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Markus Elfring <Markus.Elfring@xxxxxx> Subject: mm/mempolicy: fix exception handling in shared_policy_replace() Date: Thu, 23 Mar 2023 18:30:48 +0100 The label â??err_outâ?? was used to jump to another pointer check despite of the detail in the implementation of the function â??shared_policy_replaceâ?? that it was determined already that a corresponding variable contained a null pointer because of a failed call of the function â??kmem_cache_allocâ??. 1. Use more appropriate labels instead. 2. The implementation of the function â??mpol_putâ?? contains a pointer check   for its single input parameter.   Thus delete a redundant check in the caller. This issue was detected by using the Coccinelle software. Fixes: 42288fe366c4f1ce7522bc9f27d0bc2a81c55264 ("mm: mempolicy: Convert shared_policy mutex to spinlock") Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx> Cc: KOSAKI Motohiro <kosaki.motohiro@xxxxxxxxxxxxxx> Cc: Mel Gorman <mgorman@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/mempolicy.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) --- a/mm/mempolicy.c~mm-mempolicy-fix-exception-handling-in-shared_policy_replace +++ a/mm/mempolicy.c @@ -2736,13 +2736,12 @@ restart: sp_insert(sp, new); write_unlock(&sp->lock); ret = 0; +put_mpol: + mpol_put(mpol_new); -err_out: - if (mpol_new) - mpol_put(mpol_new); if (n_new) kmem_cache_free(sn_cache, n_new); - +exit: return ret; alloc_new: @@ -2750,10 +2749,10 @@ alloc_new: ret = -ENOMEM; n_new = kmem_cache_alloc(sn_cache, GFP_KERNEL); if (!n_new) - goto err_out; + goto exit; mpol_new = kmem_cache_alloc(policy_cache, GFP_KERNEL); if (!mpol_new) - goto err_out; + goto put_mpol; atomic_set(&mpol_new->refcnt, 1); goto restart; } _ Patches currently in -mm which might be from Markus.Elfring@xxxxxx are mm-mempolicy-fix-exception-handling-in-shared_policy_replace.patch