Commit a5d21721 authored by Sergey Senozhatsky's avatar Sergey Senozhatsky Committed by Andrew Morton

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: c7e6f17b ("zsmalloc: zs_malloc: return ERR_PTR on failure")
Signed-off-by: default avatarSergey Senozhatsky <senozhatsky@chromium.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>,
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 44e602b4
...@@ -1487,7 +1487,7 @@ void zs_free(struct zs_pool *pool, unsigned long handle) ...@@ -1487,7 +1487,7 @@ void zs_free(struct zs_pool *pool, unsigned long handle)
struct size_class *class; struct size_class *class;
enum fullness_group fullness; enum fullness_group fullness;
if (unlikely(!handle)) if (IS_ERR_OR_NULL((void *)handle))
return; return;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment