From: Alexey Romanov Date: Thu, 13 Oct 2022 11:28:25 +0000 (+0300) Subject: zsmalloc: zs_destroy_pool: add size_class NULL check X-Git-Tag: baikal/aarch64/sdk6.1~2798^2~13 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=21d62ea445cb4f075306fc2d60b76c53f15e8cc0;p=kernel.git zsmalloc: zs_destroy_pool: add size_class NULL check Inside the zs_destroy_pool() function, there can still be NULL size_class pointers: if when the next size_class is allocated, inside zs_create_pool() function, kzalloc will return NULL and handling the error condition, zs_create_pool() will call zs_destroy_pool(). Link: https://lkml.kernel.org/r/20221013112825.61869-1-avromanov@sberdevices.ru Fixes: b448e4f972cc ("zsmalloc: remove unnecessary size_class NULL check") Signed-off-by: Alexey Romanov Reviewed-by: Sergey Senozhatsky Cc: Minchan Kim Cc: Nitin Gupta Signed-off-by: Andrew Morton --- diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 525758713a553..d03941cace2c4 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -2311,6 +2311,9 @@ void zs_destroy_pool(struct zs_pool *pool) int fg; struct size_class *class = pool->size_class[i]; + if (!class) + continue; + if (class->index != i) continue;