]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
crypto: acomp - Clone folios properly
authorHerbert Xu <herbert@gondor.apana.org.au>
Thu, 1 May 2025 12:37:30 +0000 (20:37 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 5 May 2025 10:20:45 +0000 (18:20 +0800)
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
include/crypto/acompress.h

index 9dea76ed451358297133fd8da1e255204a4cc16f..6ecbfc49bfa86220800a2a3212b12cbceee0c9bb 100644 (file)
@@ -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");
index f1812e92d3e338d6a8957a0fdeae69b8b4a584a4..9eacb9fa375d75a8c1ef62c63d7ae9b40c76a033 100644 (file)
@@ -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