]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm/zsmalloc: do not attempt to free IS_ERR handle
authorSergey Senozhatsky <senozhatsky@chromium.org>
Tue, 16 Aug 2022 05:09:06 +0000 (14:09 +0900)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 17 Aug 2022 20:58:03 +0000 (13:58 -0700)
commit0a421413aca7adfa7cc8a31b8a1b04c1ff29787f
tree25dd2a17a10ee4b11d4ac658eedafecd6121deb3
parentfb71c973b5f73bc1cb1fe73b81e45b18c5932686
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 <senozhatsky@chromium.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>,
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/zsmalloc.c