From: Ira Weiny <ira.weiny@intel.com>
To: Hui Su <sh_def@163.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/vmalloc.c: check the addr first
Date: Mon, 28 Sep 2020 11:04:34 -0700 [thread overview]
Message-ID: <20200928180434.GD458519@iweiny-DESK2.sc.intel.com> (raw)
In-Reply-To: <20200927163337.GA5472@rlk>
On Mon, Sep 28, 2020 at 12:33:37AM +0800, Hui Su wrote:
> As the comments said, if @addr is NULL, no operation
> is performed, check the addr first in vfree() and
> vfree_atomic() maybe a better choice.
I don't see how this change helps anything. kmemleak_free() checks addr so no
danger there. Also kmemleak_free() contains a pr_debug() which some might find
useful.
Ira
>
> Signed-off-by: Hui Su <sh_def@163.com>
> ---
> mm/vmalloc.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index be4724b916b3..1cf50749a209 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -2305,10 +2305,11 @@ void vfree_atomic(const void *addr)
> {
> BUG_ON(in_nmi());
>
> - kmemleak_free(addr);
> -
> if (!addr)
> return;
> +
> + kmemleak_free(addr);
> +
> __vfree_deferred(addr);
> }
>
> @@ -2340,13 +2341,13 @@ void vfree(const void *addr)
> {
> BUG_ON(in_nmi());
>
> + if (!addr)
> + return;
> +
> kmemleak_free(addr);
>
> might_sleep_if(!in_interrupt());
>
> - if (!addr)
> - return;
> -
> __vfree(addr);
> }
> EXPORT_SYMBOL(vfree);
> --
> 2.25.1
>
>
>
next prev parent reply other threads:[~2020-09-28 18:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-27 16:33 Hui Su
2020-09-28 18:04 ` Ira Weiny [this message]
2020-10-08 12:11 ` Hui Su
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=20200928180434.GD458519@iweiny-DESK2.sc.intel.com \
--to=ira.weiny@intel.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=sh_def@163.com \
/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