lkml.org 
[lkml]   [2020]   [Sep]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] mm/vmalloc.c: check the addr first
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
>
>
>

\
 
 \ /
  Last update: 2020-09-28 20:05    [W:0.069 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site