]> www.infradead.org Git - users/jedix/linux-maple.git/commit
zsmalloc: zs_malloc: return ERR_PTR on failure
authorHui Zhu <teawater@antgroup.com>
Thu, 14 Jul 2022 08:07:57 +0000 (16:07 +0800)
committerakpm <akpm@linux-foundation.org>
Wed, 20 Jul 2022 21:41:51 +0000 (14:41 -0700)
commit3998b6847b6baf16d2f08b14de53bbf7c2776515
treebfa5c759ec1d9ab6b5b432395f1c947ea10624e4
parent49ad534f3d4e42468ba30e5a30b0d0f4ceba1ea9
zsmalloc: zs_malloc: return ERR_PTR on failure

zs_malloc returns 0 if it fails.  zs_zpool_malloc will return -1 when
zs_malloc return 0.  But -1 makes the return value unclear.

For example, when zswap_frontswap_store calls zs_malloc through
zs_zpool_malloc, it will return -1 to its caller.  The other return value
is -EINVAL, -ENODEV or something else.

This commit changes zs_malloc to return ERR_PTR on failure.  It didn't
just let zs_zpool_malloc return -ENOMEM becaue zs_malloc has two types of
failure:

- size is not OK return -EINVAL
- memory alloc fail return -ENOMEM.

Link: https://lkml.kernel.org/r/20220714080757.12161-1-teawater@gmail.com
Signed-off-by: Hui Zhu <teawater@antgroup.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/block/zram/zram_drv.c
mm/zsmalloc.c