Commit f1e6c548 authored by Sergey Senozhatsky's avatar Sergey Senozhatsky Committed by Jinjiang Tu
Browse files

mm/zsmalloc: do not attempt to free IS_ERR handle

mainline inclusion
from mainline-v6.0-rc3
commit a5d21721
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I7TWVA
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=a5d2172180e8f94a8cfc7a7fa0243035629bf8d0

-------------------------------------------

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>
Signed-off-by: default avatarJinjiang Tu <tujinjiang@huawei.com>
parent 50730227
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment