Re: [PATCH] mm/slub: return 0 when object pointer is NULL

From: Hyeonggon Yoo
Date: Mon Sep 12 2022 - 03:21:41 EST


On Mon, Sep 12, 2022 at 01:59:39PM +0800, Ben Luo wrote:
> NULL is definitly not a valid address
>
> Signed-off-by: Ben Luo <luoben@xxxxxxxxxxxxxxxxx>
> ---
> mm/slub.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/slub.c b/mm/slub.c
> index 862dbd9..50fad18 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -674,7 +674,7 @@ static inline int check_valid_pointer(struct kmem_cache *s,
> void *base;
>
> if (!object)
> - return 1;
> + return 0;
>
> base = slab_address(slab);
> object = kasan_reset_tag(object);
> --
> 1.8.3.1
>

Hello Ben.

The return value is used to check if the @object has valid pointer
in @slab. (used for debugging) the return value is 0 if valid, 1 if invalid.

It does not return a pointer. So changing it to 0 because 1 is invalid
address does not make sense.

--
Thanks,
Hyeonggon