From: Herbert Xu Date: Tue, 8 Apr 2025 04:20:34 +0000 (+0800) Subject: crypto: scomp - Fix null-pointer deref when freeing streams X-Git-Tag: v6.15-rc3~45^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cfb32c656eb7bf1d7a776b8793bb6baa6f58b5a4;p=thirdparty%2Fkernel%2Flinux.git crypto: scomp - Fix null-pointer deref when freeing streams As the scomp streams are freed when an algorithm is unregistered, it is possible that the algorithm has never been used at all (e.g., an algorithm that does not have a self-test). So test whether the streams exist before freeing them. Reported-by: Sourabh Jain Fixes: 3d72ad46a23a ("crypto: acomp - Move stream management into scomp layer") Signed-off-by: Herbert Xu Tested-by: Sourabh Jain Signed-off-by: Herbert Xu --- diff --git a/crypto/scompress.c b/crypto/scompress.c index d435d4b24469d..f67ce38d203d8 100644 --- a/crypto/scompress.c +++ b/crypto/scompress.c @@ -111,6 +111,9 @@ static void scomp_free_streams(struct scomp_alg *alg) struct crypto_acomp_stream __percpu *stream = alg->stream; int i; + if (!stream) + return; + for_each_possible_cpu(i) { struct crypto_acomp_stream *ps = per_cpu_ptr(stream, i);