Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1446633rwl; Fri, 24 Mar 2023 10:34:50 -0700 (PDT) X-Google-Smtp-Source: AKy350a/6U/gBxs2jd+beq92oKSu3Rl1VK0L1+lN2tIZu2WPEjse3VWWle9808w9LlJPFkd8sQLv X-Received: by 2002:a17:90b:4c0b:b0:23e:fa90:ba34 with SMTP id na11-20020a17090b4c0b00b0023efa90ba34mr3786322pjb.37.1679679290156; Fri, 24 Mar 2023 10:34:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679679290; cv=none; d=google.com; s=arc-20160816; b=FL04sEs99uZBA6rl3K6gCkfOa9nxw6WdcmpsGnZI/bIwYlXJ2nzgxbdf8lJXIdgLsG pHvX6tFGtLhMhtMyRREX2xnThWglT1cuSsUjpW/iBcjRmQvUl/bAv+N5ZjpOPWd61J7Z D/9xvoNM+dh5oxRaT4JQOgchCnA7mNLz/qUSgJSTzGRdRbSpGzxqIPFNBFWcoyohEYSh 6UxmL4r/Z4fJXdzB6NPDipUXc/5LBjokV0DAB1r7vPhpz/Qe5I2ZrUJqcJ1CPiPZQQ1n gcj6Iz6ZbGxbW5JmsEqYy5c+gy/alw7gwEeBbH2tUDg9LEY6H3Of+lZ8VSS+NAgDBZ1H W+KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=+eiBbPs2SGpkrGMAzRmJfw7VfJ2mVEesg1+9LMIwCTE=; b=bhYZI1cvV7DJrVze3/ppGWprZ28l6bcKZMqB/lN0A6SgzFMkujzBxW0j1FcG/SusS4 CxNiyMNHOb7rwEuPqgsz1Pd9+HaNwMODgA4gStNUuLZzjbrFyAP1glGI7fq0xDSC+na5 xUmPMxlseXGEbvhkmHH2/y3bmXOfSLj8ZJE2a531KPkkcm0EXbOsgrBQr/FK6s1KnF4p lIc/eTXIv3EqoH6fX4SQVr07G4Bni5Y/ZFQvxjhDSKO024Q7zb6AS9L8jqTFnobBzOLj ww+vDurwaNjXjq0E5dwEW8fDoEE6ThEcKEIG3E+jd0bEum/UpBxNSn6CKw8xN/tEp7E4 oo5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=O46wtOse; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=kZxNL7ER; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q65-20020a632a44000000b0050fa6fbde46si10642398pgq.492.2023.03.24.10.34.34; Fri, 24 Mar 2023 10:34:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=O46wtOse; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=kZxNL7ER; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230382AbjCXRaJ (ORCPT + 99 others); Fri, 24 Mar 2023 13:30:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229917AbjCXRaG (ORCPT ); Fri, 24 Mar 2023 13:30:06 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C54A0B77E; Fri, 24 Mar 2023 10:30:04 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3C84B33B63; Fri, 24 Mar 2023 17:30:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1679679003; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+eiBbPs2SGpkrGMAzRmJfw7VfJ2mVEesg1+9LMIwCTE=; b=O46wtOse/KmGUQx3zAOgmnpK5rrOILvob0lQT3LYNVP7LUFw5YuoY//8OHIp6KT0MNxCHo MYZwqgBqXt6vRaC6aEhRCHHQiHaZza4Y/0Kuf9ukEoN5OYPwHVFcTlGU2ggU02D0FPqGB9 3gLQ6K+0fi+cQMMx4ZZwx0oQ4qFbSO4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1679679003; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+eiBbPs2SGpkrGMAzRmJfw7VfJ2mVEesg1+9LMIwCTE=; b=kZxNL7ERELRnFYwUZ1ebrmvqaNDYDiayXb27qqSoFZGsuJnXQvUdyMeOAvHr1aae7uMsCB guhevfdq+HG2fzAw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 171F5138ED; Fri, 24 Mar 2023 17:30:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id BiLnBBveHWQ8LQAAMHmgww (envelope-from ); Fri, 24 Mar 2023 17:30:03 +0000 Message-ID: <22a1ec75-155a-2392-ce39-4bca3fc081eb@suse.cz> Date: Fri, 24 Mar 2023 18:30:02 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH] mm/mempolicy: Fix exception handling in shared_policy_replace() Content-Language: en-US To: Markus Elfring , kernel-janitors@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Kosaki Motohiro , Mel Gorman Cc: cocci@inria.fr, LKML References: <6e9ca062-939b-af96-c8ff-56ad485d6e79@web.de> From: Vlastimil Babka In-Reply-To: <6e9ca062-939b-af96-c8ff-56ad485d6e79@web.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Your patch doesn't apply, seems like it uses spaces instead of tabs. Also I can't use 'b4' to download it as there are multiple different patches using the same message-id: https://lore.kernel.org/all/6e9ca062-939b-af96-c8ff-56ad485d6e79@web.de/ Re: subject, I don't see a bug that this would fix. You could say it's "cleanup" and this function could use one, but for a cleanup it's not improving the situation much. On 3/23/23 18:30, Markus Elfring wrote: > Date: Thu, 23 Mar 2023 18:18:59 +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") Again this is not a fix. > Signed-off-by: Markus Elfring > --- >  mm/mempolicy.c | 11 +++++------ >  1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/mm/mempolicy.c b/mm/mempolicy.c > index a256a241fd1d..fb0485688dcb 100644 > --- a/mm/mempolicy.c > +++ b/mm/mempolicy.c > @@ -2736,13 +2736,12 @@ static int shared_policy_replace(struct shared_policy *sp, unsigned long start, >          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 @@ static int shared_policy_replace(struct shared_policy *sp, unsigned long start, >      ret = -ENOMEM; >      n_new = kmem_cache_alloc(sn_cache, GFP_KERNEL); >      if (!n_new) > -        goto err_out; > +        goto exit; Just "return ret" and no need for exit label? >      mpol_new = kmem_cache_alloc(policy_cache, GFP_KERNEL); >      if (!mpol_new) > -        goto err_out; > +        goto put_mpol; We are doing this because mpol_new == NULL, so we know there's no reason to do mpol_put(), we could jump to the freeing of n_new. >      atomic_set(&mpol_new->refcnt, 1); >      goto restart; >  } > -- > 2.40.0 > > >