Skip to content

Commit cfb32c6

Browse files
committed
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 <sourabhjain@linux.ibm.com> Fixes: 3d72ad4 ("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>
1 parent 1ddaff4 commit cfb32c6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

crypto/scompress.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ static void scomp_free_streams(struct scomp_alg *alg)
111111
struct crypto_acomp_stream __percpu *stream = alg->stream;
112112
int i;
113113

114+
if (!stream)
115+
return;
116+
114117
for_each_possible_cpu(i) {
115118
struct crypto_acomp_stream *ps = per_cpu_ptr(stream, i);
116119

0 commit comments

Comments
 (0)