linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yang Shi <yang.shi@linux.alibaba.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: David Hildenbrand <david@redhat.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] mm: vmpressure: don't need call kfree if kstrndup fails
Date: Wed, 12 Feb 2020 20:51:22 -0800	[thread overview]
Message-ID: <a1876cc1-fe27-2e30-332e-67d4345b0dd1@linux.alibaba.com> (raw)
In-Reply-To: <20200212204827.df1de9015a3c03c79a8d7155@linux-foundation.org>



On 2/12/20 8:48 PM, Andrew Morton wrote:
> On Wed, 12 Feb 2020 19:14:27 -0800 Yang Shi <yang.shi@linux.alibaba.com> wrote:
>
>> On 2/12/20 3:21 AM, David Hildenbrand wrote:
>>> On 11.02.20 06:24, Yang Shi wrote:
>>>> When kstrndup fails (returns NULL) there is no memory is allocated by
>>>> kmalloc, so no need to call kfree().
>>> "When kstrndup fails, no memory was allocated and we can exit directly."
>> Thanks for correcting the commit log.
>>
>> Andrew, do you prefer I send an updated version or you would just update
>> the patch in -mm tree?
> I have already done this.

Thanks!

>
> From: Yang Shi <yang.shi@linux.alibaba.com>
> Subject: mm: vmpressure: don't need call kfree if kstrndup fails
>
> When kstrndup fails, no memory was allocated and we can exit directly.
>
> [david@redhat.com: reword changelog]
> Link: http://lkml.kernel.org/r/1581398649-125989-1-git-send-email-yang.shi@linux.alibaba.com
> Signed-off-by: Yang Shi <yang.shi@linux.alibaba.com>
> Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
> Reviewed-by: David Hildenbrand <david@redhat.com>
> Acked-by: David Rientjes <rientjes@google.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
>
>   mm/vmpressure.c |    6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
>
> --- a/mm/vmpressure.c~mm-vmpressure-dont-need-call-kfree-if-kstrndup-fails
> +++ a/mm/vmpressure.c
> @@ -371,10 +371,8 @@ int vmpressure_register_event(struct mem
>   	int ret = 0;
>   
>   	spec_orig = spec = kstrndup(args, MAX_VMPRESSURE_ARGS_LEN, GFP_KERNEL);
> -	if (!spec) {
> -		ret = -ENOMEM;
> -		goto out;
> -	}
> +	if (!spec)
> +		return -ENOMEM;
>   
>   	/* Find required level */
>   	token = strsep(&spec, ",");
> _



      reply	other threads:[~2020-02-13  4:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-11  5:24 [PATCH 1/2] mm: vmpressure: don't need call kfree if kstrndup fails Yang Shi
2020-02-11  5:24 ` [PATCH 2/2] mm: vmpressure: use mem_cgroup_is_root API Yang Shi
2020-02-12  2:08   ` David Rientjes
2020-02-12  8:23   ` Michal Hocko
2020-02-13  3:18     ` Yang Shi
2020-02-12 11:19   ` David Hildenbrand
2020-02-12  2:07 ` [PATCH 1/2] mm: vmpressure: don't need call kfree if kstrndup fails David Rientjes
2020-02-12 11:21 ` David Hildenbrand
2020-02-13  3:14   ` Yang Shi
2020-02-13  4:48     ` Andrew Morton
2020-02-13  4:51       ` Yang Shi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a1876cc1-fe27-2e30-332e-67d4345b0dd1@linux.alibaba.com \
    --to=yang.shi@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).