From: Sergey Senozhatsky Date: Fri, 12 Jul 2024 05:18:14 +0000 (+0900) Subject: lib: zstd: fix null-deref in ZSTD_createCDict_advanced2() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=9701a8a0dd9421f7788792958c66c46eb0c067f6;p=users%2Fjedix%2Flinux-maple.git lib: zstd: fix null-deref in ZSTD_createCDict_advanced2() ZSTD_createCDict_advanced2() must ensure that ZSTD_createCDict_advanced_internal() has successfully allocated cdict. customMalloc() may be called under low memory condition and may be unable to allocate workspace for cdict. Link: https://lkml.kernel.org/r/20240712051850.484318-4-senozhatsky@chromium.org Signed-off-by: Sergey Senozhatsky Cc: Nick Terrell Cc: Minchan Kim Cc: Nhat Pham Cc: Nitin Gupta Signed-off-by: Andrew Morton --- diff --git a/lib/zstd/compress/zstd_compress.c b/lib/zstd/compress/zstd_compress.c index f620cafca633b..16bb995bc6c4c 100644 --- a/lib/zstd/compress/zstd_compress.c +++ b/lib/zstd/compress/zstd_compress.c @@ -4810,6 +4810,8 @@ ZSTD_CDict* ZSTD_createCDict_advanced2( dictLoadMethod, cctxParams.cParams, cctxParams.useRowMatchFinder, cctxParams.enableDedicatedDictSearch, customMem); + if (!cdict) + return NULL; if (ZSTD_isError( ZSTD_initCDict_internal(cdict, dict, dictSize,