]> git.baikalelectronics.ru Git - kernel.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>
Sun, 28 Aug 2022 21:02:44 +0000 (14:02 -0700)
commitb9ac9e13021cd6f07bba713c0daf2466d5ad8183
treef928252b9aafe2a463ad3aa31457b297ba7fc0fc
parent1561d3aedb2055491040f88e52e8449e6338ba6b
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: 1e2938d4b321 ("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