public inbox for linux-crypto@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: acomp - fix wrong pointer in acomp_reqchain_done()
@ 2026-03-24 18:07 Giovanni Cabiddu
  2026-04-03  0:44 ` Herbert Xu
  0 siblings, 1 reply; 4+ messages in thread
From: Giovanni Cabiddu @ 2026-03-24 18:07 UTC (permalink / raw)
  To: herbert
  Cc: linux-crypto, qat-linux, Giovanni Cabiddu, Laurent M Coquerel,
	Wojciech Drewek, Andy Shevchenko

acomp_save_req() stores a pointer to req->chain in req->base.data:

    req->base.data = state;  /* state = &req->chain */

When a driver completes asynchronously, acomp_reqchain_done() receives
this pointer as its data argument. However, it incorrectly casts the
data pointer to a struct acomp_req.

Use container_of() to recover the enclosing acomp_req from the chain
member pointer.

Fixes: 64929fe8c0a4 ("crypto: acomp - Remove request chaining")
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Reviewed-by: Laurent M Coquerel <laurent.m.coquerel@intel.com>
Reviewed-by: Wojciech Drewek <wojciech.drewek@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
---
 crypto/acompress.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/crypto/acompress.c b/crypto/acompress.c
index 1f9cb04b447f..deb50c078f80 100644
--- a/crypto/acompress.c
+++ b/crypto/acompress.c
@@ -9,6 +9,7 @@
 
 #include <crypto/internal/acompress.h>
 #include <crypto/scatterwalk.h>
+#include <linux/container_of.h>
 #include <linux/cryptouser.h>
 #include <linux/cpumask.h>
 #include <linux/err.h>
@@ -251,7 +252,7 @@ static int acomp_reqchain_finish(struct acomp_req *req, int err)
 
 static void acomp_reqchain_done(void *data, int err)
 {
-	struct acomp_req *req = data;
+	struct acomp_req *req = container_of(data, struct acomp_req, chain);
 	crypto_completion_t compl;
 
 	compl = req->chain.compl;
-- 
2.53.0


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

end of thread, other threads:[~2026-04-17  8:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-24 18:07 [PATCH] crypto: acomp - fix wrong pointer in acomp_reqchain_done() Giovanni Cabiddu
2026-04-03  0:44 ` Herbert Xu
2026-04-16 17:07   ` [PATCH] crypto: acomp - fix wrong pointer stored by acomp_save_req() Giovanni Cabiddu
2026-04-17  8:51     ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox