]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
crypto: scomp - Fix null-pointer deref when freeing streams
authorHerbert Xu <herbert@gondor.apana.org.au>
Tue, 8 Apr 2025 04:20:34 +0000 (12:20 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Wed, 9 Apr 2025 13:28:31 +0000 (21:28 +0800)
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 <sourabhjain@linux.ibm.com>
Fixes: 3d72ad46a23a ("crypto: acomp - Move stream management into scomp layer")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Tested-by: Sourabh Jain <sourabhjain@linux.ibm.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/scompress.c

index d435d4b24469d460d324dd62be9e9706ff52aecb..f67ce38d203d84283044740defe27fd22736ab62 100644 (file)
@@ -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);