diff mbox series

[1/4] crypto: acomp - Clone folios properly

Message ID e4ca39a0ada7deaaf86dd1a40a717b30cc3e462f.1746102673.git.herbert@gondor.apana.org.au
State New
Headers show
Series crypto: acomp - Add compression segmentation support | expand

Commit Message

Herbert Xu May 1, 2025, 12:37 p.m. UTC
The folios contain references to the request itself so they must
be setup again in the cloned request.

Fixes: 5f3437e9c89e ("crypto: acomp - Simplify folio handling")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
 crypto/acompress.c         | 18 ++++++++++++++++++
 include/crypto/acompress.h |  8 ++------
 2 files changed, 20 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/crypto/acompress.c b/crypto/acompress.c
index 9dea76ed4513..6ecbfc49bfa8 100644
--- a/crypto/acompress.c
+++ b/crypto/acompress.c
@@ -566,5 +566,23 @@  int acomp_walk_virt(struct acomp_walk *__restrict walk,
 }
 EXPORT_SYMBOL_GPL(acomp_walk_virt);
 
+struct acomp_req *acomp_request_clone(struct acomp_req *req,
+				      size_t total, gfp_t gfp)
+{
+	struct acomp_req *nreq;
+
+	nreq = container_of(crypto_request_clone(&req->base, total, gfp),
+			    struct acomp_req, base);
+	if (nreq == req)
+		return req;
+
+	if (req->src == &req->chain.ssg)
+		nreq->src = &nreq->chain.ssg;
+	if (req->dst == &req->chain.dsg)
+		nreq->dst = &nreq->chain.dsg;
+	return nreq;
+}
+EXPORT_SYMBOL_GPL(acomp_request_clone);
+
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Asynchronous compression type");
diff --git a/include/crypto/acompress.h b/include/crypto/acompress.h
index f1812e92d3e3..9eacb9fa375d 100644
--- a/include/crypto/acompress.h
+++ b/include/crypto/acompress.h
@@ -551,11 +551,7 @@  static inline struct acomp_req *acomp_request_on_stack_init(
 	return req;
 }
 
-static inline struct acomp_req *acomp_request_clone(struct acomp_req *req,
-						    size_t total, gfp_t gfp)
-{
-	return container_of(crypto_request_clone(&req->base, total, gfp),
-			    struct acomp_req, base);
-}
+struct acomp_req *acomp_request_clone(struct acomp_req *req,
+				      size_t total, gfp_t gfp);
 
 #endif