All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] crypto: scomp - Fix memory leak on module unload
@ 2025-03-16  9:50 Herbert Xu
  2025-03-16  9:50 ` [PATCH 1/2] crypto: scompress - Fix incorrect stream freeing Herbert Xu
  2025-03-16  9:50 ` [PATCH 2/2] crypto: api - Call crypto_alg_put in crypto_unregister_alg Herbert Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Herbert Xu @ 2025-03-16  9:50 UTC (permalink / raw)
  To: Linux Crypto Mailing List

This mini series fixes the leaking of stream memory when an scomp
algorith module is unloaded.

Herbert Xu (2):
  crypto: scompress - Fix incorrect stream freeing
  crypto: api - Call crypto_alg_put in crypto_unregister_alg

 crypto/algapi.c    | 3 +--
 crypto/scompress.c | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

-- 
2.39.5


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] crypto: scompress - Fix incorrect stream freeing
  2025-03-16  9:50 [PATCH 0/2] crypto: scomp - Fix memory leak on module unload Herbert Xu
@ 2025-03-16  9:50 ` Herbert Xu
  2025-03-16  9:50 ` [PATCH 2/2] crypto: api - Call crypto_alg_put in crypto_unregister_alg Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2025-03-16  9:50 UTC (permalink / raw)
  To: Linux Crypto Mailing List

Fix stream freeing crash by passing the correct pointer.

Fixes: 3d72ad46a23a ("crypto: acomp - Move stream management into scomp layer")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
 crypto/scompress.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crypto/scompress.c b/crypto/scompress.c
index 57bb7353d767..d4be977b9729 100644
--- a/crypto/scompress.c
+++ b/crypto/scompress.c
@@ -117,7 +117,7 @@ static void scomp_free_streams(struct scomp_alg *alg)
 		if (!ps->ctx)
 			break;
 
-		alg->free_ctx(ps);
+		alg->free_ctx(ps->ctx);
 	}
 
 	free_percpu(stream);
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] crypto: api - Call crypto_alg_put in crypto_unregister_alg
  2025-03-16  9:50 [PATCH 0/2] crypto: scomp - Fix memory leak on module unload Herbert Xu
  2025-03-16  9:50 ` [PATCH 1/2] crypto: scompress - Fix incorrect stream freeing Herbert Xu
@ 2025-03-16  9:50 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2025-03-16  9:50 UTC (permalink / raw)
  To: Linux Crypto Mailing List

Instead of calling cra_destroy by hand, call it through
crypto_alg_put so that the correct unwinding functions are called
through crypto_destroy_alg.

Fixes: 3d6979bf3bd5 ("crypto: api - Add cra_type->destroy hook")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
 crypto/algapi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/crypto/algapi.c b/crypto/algapi.c
index e7a9a2ada2cf..ea9ed9580aa8 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -464,8 +464,7 @@ void crypto_unregister_alg(struct crypto_alg *alg)
 	if (WARN_ON(refcount_read(&alg->cra_refcnt) != 1))
 		return;
 
-	if (alg->cra_destroy)
-		alg->cra_destroy(alg);
+	crypto_alg_put(alg);
 
 	crypto_remove_final(&list);
 }
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-16  9:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-16  9:50 [PATCH 0/2] crypto: scomp - Fix memory leak on module unload Herbert Xu
2025-03-16  9:50 ` [PATCH 1/2] crypto: scompress - Fix incorrect stream freeing Herbert Xu
2025-03-16  9:50 ` [PATCH 2/2] crypto: api - Call crypto_alg_put in crypto_unregister_alg Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.