From: Sergey Senozhatsky Date: Tue, 16 Aug 2022 05:09:06 +0000 (+0900) Subject: mm/zsmalloc: do not attempt to free IS_ERR handle X-Git-Tag: v6.1-rc5~514^2~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a5d2172180e8f94a8cfc7a7fa0243035629bf8d0;p=platform%2Fkernel%2Flinux-starfive.git mm/zsmalloc: do not attempt to free IS_ERR handle zsmalloc() now returns ERR_PTR values as handles, which zram accidentally can pass to zs_free(). Another bad scenario is when zcomp_compress() fails - handle has default -ENOMEM value, and zs_free() will try to free that "pointer value". Add the missing check and make sure that zs_free() bails out when ERR_PTR() is passed to it. Link: https://lkml.kernel.org/r/20220816050906.2583956-1-senozhatsky@chromium.org Fixes: c7e6f17b52e9 ("zsmalloc: zs_malloc: return ERR_PTR on failure") Signed-off-by: Sergey Senozhatsky Cc: Minchan Kim Cc: Nitin Gupta , Signed-off-by: Andrew Morton --- diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 34f784a..907c9b1 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1487,7 +1487,7 @@ void zs_free(struct zs_pool *pool, unsigned long handle) struct size_class *class; enum fullness_group fullness; - if (unlikely(!handle)) + if (IS_ERR_OR_NULL((void *)handle)) return; /*