Commit cfb32c65 authored by Herbert Xu's avatar Herbert Xu
Browse files

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: default avatarSourabh Jain <sourabhjain@linux.ibm.com>
Fixes: 3d72ad46 ("crypto: acomp - Move stream management into scomp layer")
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Tested-by: default avatarSourabh Jain <sourabhjain@linux.ibm.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 1ddaff40
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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);