crypto: acomp - Add compression segmentation support
Subsystems (2)
Herbert Xu
maintainercover crypto: acomp - Add compression segmentation support
This patch series is a reboot of the acomp multibuffer patch series. Instead of using request chaining, this time it is done using a plain SG list and a unit size.
Either the Crypto API or optionally the algorithm can dice up the request into unit-sized pieces. The caller provides a single page and a 2-entry SG list for output, and the Crypto API or algorithm will dynamically extend it one page at a time through chaining if necessary. The compressed result will be tightly packed together.
If any unit fails to compress, a zero-length SG entry will be inserted for it.
If at any time memory allocation fails (the first entry cannot fail since it's compressed into memory provided by the caller), then compression will stop and the caller can process what has been compressed so far before resuming by calling with an offset into the original SG list.
Herbert Xu (4):
crypto: acomp - Clone folios properly
crypto: api - Rename CRYPTO_ALG_REQ_CHAIN to CRYPTO_ALG_REQ_VIRT
crypto: acomp - Add compression segmentation support
crypto: testmgr - Add multibuffer acomp testing
crypto/acompress.c | 172 ++++++++++++++++++++++++++-- crypto/ahash.c | 6 +- crypto/algapi.c | 3 + crypto/deflate.c | 2 +- crypto/scompress.c | 2 +- crypto/testmgr.c | 145 ++++++++++++----------- include/crypto/acompress.h | 107 +++++++++++++++-- include/crypto/algapi.h | 9 +- include/crypto/internal/acompress.h | 14 ++- include/crypto/internal/hash.h | 4 +- include/linux/crypto.h | 7 +- 11 files changed, 367 insertions(+), 104 deletions(-)
Signature · 1 line
2.39.5
Herbert Xu
maintainerPATCH 1/4 crypto: acomp - Clone folios properly
The folios contain references to the request itself so they must be setup again in the cloned request.
--- crypto/acompress.c | 18 ++++++++++++++++++ include/crypto/acompress.h | 8 ++------ 2 files changed, 20 insertions(+), 6 deletions(-)
crypto/acompress.c +18 -0
@@ -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" );
include/crypto/acompress.h +2 -6
@@ -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
Signature · 1 line
2.39.5
Herbert Xu
maintainerPATCH 2/4 crypto: api - Rename CRYPTO_ALG_REQ_CHAIN to CRYPTO_ALG_REQ_VIRT
In reply to Herbert XuAs chaining has been removed, all that remains of REQ_CHAIN is just virtual address support. Rename it before the reintroduction of batching creates confusion.
--- crypto/acompress.c | 4 ++-- crypto/ahash.c | 6 +++--- crypto/deflate.c | 2 +- crypto/scompress.c | 2 +- include/crypto/algapi.h | 4 ++-- include/crypto/internal/acompress.h | 4 ++-- include/crypto/internal/hash.h | 4 ++-- include/linux/crypto.h | 4 ++-- 8 files changed, 15 insertions(+), 15 deletions(-)
crypto/acompress.c +2 -2
@@ -287,7 +287,7 @@ int crypto_acomp_compress(struct acomp_req *req)if (acomp_req_on_stack (req) &&acomp_is_async (tfm))return -EAGAIN ; -if (crypto_acomp_req_chain (tfm) ||acomp_request_issg (req)) +if (crypto_acomp_req_virt (tfm) ||acomp_request_issg (req))return crypto_acomp_reqtfm (req)->compress (req);return acomp_do_req_chain (req, true); }
@@ -299,7 +299,7 @@ int crypto_acomp_decompress(struct acomp_req *req)if (acomp_req_on_stack (req) &&acomp_is_async (tfm))return -EAGAIN ; -if (crypto_acomp_req_chain (tfm) ||acomp_request_issg (req)) +if (crypto_acomp_req_virt (tfm) ||acomp_request_issg (req))return crypto_acomp_reqtfm (req)->decompress (req);return acomp_do_req_chain (req, false); }
crypto/ahash.c +3 -3
@@ -407,7 +407,7 @@ static int ahash_do_req_chain(struct ahash_request *req,u8 *page =NULL ;int err; -if (crypto_ahash_req_chain (tfm) || +if (crypto_ahash_req_virt (tfm) || !update || !ahash_request_isvirt (req))return op (req);
@@ -550,7 +550,7 @@ int crypto_ahash_finup(struct ahash_request *req)if (ahash_req_on_stack (req) &&ahash_is_async (tfm))return -EAGAIN ;if (!crypto_ahash_alg (tfm)->finup || - (!crypto_ahash_req_chain (tfm) &&ahash_request_isvirt (req))) + (!crypto_ahash_req_virt (tfm) &&ahash_request_isvirt (req)))return ahash_def_finup (req);return ahash_do_req_chain (req,crypto_ahash_alg (tfm)->finup); }
@@ -622,7 +622,7 @@ int crypto_ahash_digest(struct ahash_request *req)return shash_ahash_digest (req,prepare_shash_desc (req, tfm));if (ahash_req_on_stack (req) &&ahash_is_async (tfm))return -EAGAIN ; -if (!crypto_ahash_req_chain (tfm) &&ahash_request_isvirt (req)) +if (!crypto_ahash_req_virt (tfm) &&ahash_request_isvirt (req))return ahash_def_digest (req);if (crypto_ahash_get_flags (tfm) &CRYPTO_TFM_NEED_KEY )return -ENOKEY ;
crypto/deflate.c +1 -1
@@ -228,7 +228,7 @@ static struct acomp_alg acomp = { .init = deflate_init, .base.cra_name = "deflate", .base.cra_driver_name = "deflate-generic", - .base.cra_flags = CRYPTO_ALG_REQ_CHAIN, + .base.cra_flags = CRYPTO_ALG_REQ_VIRT, .base.cra_module = THIS_MODULE, };
crypto/scompress.c +1 -1
@@ -355,7 +355,7 @@ static void scomp_prepare_alg(struct scomp_alg *alg)comp_prepare_alg (&alg->calg); - base->cra_flags |=CRYPTO_ALG_REQ_CHAIN ; + base->cra_flags |=CRYPTO_ALG_REQ_VIRT ; }int crypto_register_scomp (struct scomp_alg *alg)
include/crypto/algapi.h +2 -2
@@ -255,9 +255,9 @@ static inline u32 crypto_tfm_alg_type(struct crypto_tfm *tfm)return tfm->__crt_alg->cra_flags &CRYPTO_ALG_TYPE_MASK ; } -static inline bool crypto_tfm_req_chain (struct crypto_tfm *tfm) +static inline bool crypto_tfm_req_virt (struct crypto_tfm *tfm) { -return tfm->__crt_alg->cra_flags &CRYPTO_ALG_REQ_CHAIN ; +return tfm->__crt_alg->cra_flags &CRYPTO_ALG_REQ_VIRT ; }static inline u32 crypto_request_flags (struct crypto_async_request *req)
include/crypto/internal/acompress.h +2 -2
@@ -186,9 +186,9 @@ static inline bool acomp_request_isnondma(struct acomp_req *req) CRYPTO_ACOMP_REQ_DST_NONDMA); } -static inline bool crypto_acomp_req_chain (struct crypto_acomp *tfm) +static inline bool crypto_acomp_req_virt (struct crypto_acomp *tfm) { -return crypto_tfm_req_chain (&tfm->base); +return crypto_tfm_req_virt (&tfm->base); }void crypto_acomp_free_streams (struct crypto_acomp_streams *s);
include/crypto/internal/hash.h +2 -2
@@ -267,9 +267,9 @@ static inline bool ahash_request_isvirt(struct ahash_request *req)return req->base.flags &CRYPTO_AHASH_REQ_VIRT ; } -static inline bool crypto_ahash_req_chain (struct crypto_ahash *tfm) +static inline bool crypto_ahash_req_virt (struct crypto_ahash *tfm) { -return crypto_tfm_req_chain (&tfm->base); +return crypto_tfm_req_virt (&tfm->base); }static inline struct crypto_ahash *crypto_ahash_fb (struct crypto_ahash *tfm)
include/linux/crypto.h +2 -2
@@ -133,8 +133,8 @@*/ #define CRYPTO_ALG_FIPS_INTERNAL 0x00020000 -/* Set if the algorithm supports request chains and virtual addresses. */ -#define CRYPTO_ALG_REQ_CHAIN 0x00040000 +/* Set if the algorithm supports virtual addresses. */ +#define CRYPTO_ALG_REQ_VIRT 0x00040000/* The high bits 0xff000000 are reserved for type-specific flags. */
Signature · 1 line
2.39.5
Herbert Xu
maintainerPATCH 3/4 crypto: acomp - Add compression segmentation support
In reply to Herbert XuAdd support for compression after segmentation. The caller shall specify a unit size, and the API will divide the source SG list into the units of that size, before compression.
That caller shall supply a single page in a 2-entry SG list for output to seed the operation. The API will allocate more pages if necessary and extend the SG list by chaining.
If there is an allocation failure the operation will stop and partial results can be processed with the rest continued in a new operation with an updated offset in the source SG list.
--- crypto/acompress.c | 152 ++++++++++++++++++++++++++-- crypto/algapi.c | 3 + include/crypto/acompress.h | 103 +++++++++++++++++-- include/crypto/algapi.h | 5 + include/crypto/internal/acompress.h | 10 ++ include/linux/crypto.h | 3 + 6 files changed, 263 insertions(+), 13 deletions(-)
crypto/acompress.c +146 -6
@@ -18,6 +18,7 @@#include <linux/scatterlist.h> #include <linux/sched.h> #include <linux/seq_file.h> +#include <linux/slab.h> #include <linux/smp.h> #include <linux/spinlock.h> #include <linux/string.h>
@@ -234,7 +235,7 @@ static int acomp_do_nondma(struct acomp_req *req, bool comp)return err; } -static int acomp_do_one_req (struct acomp_req *req,bool comp) +static int acomp_do_linear (struct acomp_req *req,bool comp) {if (acomp_request_isnondma (req))return acomp_do_nondma (req, comp);
@@ -244,9 +245,100 @@ static int acomp_do_one_req(struct acomp_req *req, bool comp)crypto_acomp_reqtfm (req)->decompress (req); } +static void acomp_restore_cur (struct acomp_req *req) +{ + req->src->length += req->src->offset - req->chain.osoff; + req->src->offset = req->chain.osoff; +} + +static void acomp_restore_unit (struct acomp_req *req) +{ +acomp_restore_cur (req); + req->src = req->chain.ossg; + req->dst = req->chain.odsg; + req->slen = req->chain.oslen; + req->dlen = req->chain.unit; + req->base.flags |=CRYPTO_ACOMP_REQ_SRC_SEG ; +} +static int acomp_reqchain_finish (struct acomp_req *req,int err) { -acomp_reqchain_virt (req); +if (!req->chain.unit) { +acomp_reqchain_virt (req); + goto out; + } + +for (;;) { +unsigned int dlen = err ?0 : req->dlen; +unsigned int todo = req->slen; +struct page *page =NULL ; +struct scatterlist *sg; +unsigned int remain; + + req->dst->dma_address =0 ; +if (req->dst->length < dlen) { + dlen -= req->dst->length; + req->dst->dma_address =1 ; + req->dst =sg_next (req->dst); + } + req->dst->length = dlen; + +if (!(req->chain.slen -= todo)) +break ; + +if (req->src->length > todo) { + req->src->length -= todo; + req->src->offset += todo; + } + + remain = todo - req->src->length; +acomp_restore_cur (req); + req->src =sg_next (req->src); + req->chain.osoff = req->src->offset; + req->src->length -= remain; + req->src->offset += remain; + + todo =min (req->chain.unit, req->chain.slen); + req->slen = todo; + + remain =PAGE_SIZE - req->dst->offset - req->dst->length; +if (!sg_is_last (req->dst)) + page =sg_page (req->dst +1 ); +else if (remain < todo) { + page =alloc_page (GFP_ATOMIC ); +if (!page) +break ; + } + + sg =kmalloc_array (2 - !remain + !!page, +sizeof (*sg),GFP_ATOMIC ); +if (!sg) { +__free_page (page); +break ; + } + +sg_unmark_end (req->dst); +sg_chain (req->dst,2 , sg); + +sg_init_table (sg, !!remain + !!page); +if (remain) +sg_set_page (sg,sg_page (req->dst), + remain,PAGE_SIZE - remain); +if (page) +sg_set_page (sg + !!remain, page,PAGE_SIZE ,0 ); + + req->dst = sg; + req->dlen = todo; + + err =crypto_acomp_reqtfm (req)->compress (req); +if (err == -EINPROGRESS || err == -EBUSY ) +return err; + } + +acomp_restore_unit (req); + err =0 ; + +out:acomp_restore_req (req);return err; }
@@ -268,16 +360,61 @@ static void acomp_reqchain_done(void *data, int err)compl (data, err); } +void acomp_free_sgl (struct scatterlist *sg) +{ +struct page *page0; + + page0 =sg_page (sg); + sg =sg_next (sg); +while (sg) { +struct scatterlist *nsg =sg_next (sg); +struct page *page =sg_page (sg); + +if (page != page0) +__free_page (page); + +kfree (sg); + sg = nsg; + } +} +EXPORT_SYMBOL_GPL (acomp_free_sgl); +static int acomp_do_req_chain (struct acomp_req *req,bool comp) { +unsigned int todo;int err;acomp_save_req (req, acomp_reqchain_done); +if (!acomp_request_isunit (req)) { + req->chain.unit =0 ; + err =acomp_do_linear (req, comp); + goto out; + } - err =acomp_do_one_req (req, comp); -if (err == -EBUSY || err == -EINPROGRESS ) +if (req->dst->offset || req->dst->length !=PAGE_SIZE ) +return -EINVAL ; +if (!req->dlen) +return -EINVAL ; + + req->base.flags &= ~CRYPTO_ACOMP_REQ_SRC_SEG ; + + req->chain.ossg = req->src; + req->chain.odsg = req->dst; + req->chain.oslen = req->slen; + req->chain.unit = req->dlen; + + req->chain.osoff = req->src->offset; + req->chain.slen = req->slen; + + todo =min (req->chain.unit, req->chain.slen); + req->slen = todo; + req->dlen = todo; + + err =crypto_acomp_reqtfm (req)->compress (req); + +out: +if (err == -EINPROGRESS || err == -EBUSY )return err; -return acomp_reqchain_finish (req, err); }
@@ -287,7 +424,8 @@ int crypto_acomp_compress(struct acomp_req *req)if (acomp_req_on_stack (req) &&acomp_is_async (tfm))return -EAGAIN ; -if (crypto_acomp_req_virt (tfm) ||acomp_request_issg (req)) +if ((crypto_acomp_req_virt (tfm) ||acomp_request_issg (req)) && + (crypto_acomp_req_seg (tfm) || !acomp_request_isunit (req)))return crypto_acomp_reqtfm (req)->compress (req);return acomp_do_req_chain (req, true); }
@@ -299,6 +437,8 @@ int crypto_acomp_decompress(struct acomp_req *req)if (acomp_req_on_stack (req) &&acomp_is_async (tfm))return -EAGAIN ; +if (acomp_request_isunit (req)) +return -ENOSYS ;if (crypto_acomp_req_virt (tfm) ||acomp_request_issg (req))return crypto_acomp_reqtfm (req)->decompress (req);return acomp_do_req_chain (req, false);
crypto/algapi.c +3 -0
@@ -59,6 +59,9 @@ static int crypto_check_alg(struct crypto_alg *alg)if (alg->cra_priority <0 )return -EINVAL ; +if (alg->cra_flags &CRYPTO_ALG_REQ_SEG ) + alg->cra_flags |=CRYPTO_ALG_REQ_VIRT ; +refcount_set (&alg->cra_refcnt,1 );return 0 ;
include/crypto/acompress.h +96 -7
162 lines not on this page · raw message
include/crypto/algapi.h +5 -0
@@ -260,6 +260,11 @@ static inline bool crypto_tfm_req_virt(struct crypto_tfm *tfm)return tfm->__crt_alg->cra_flags &CRYPTO_ALG_REQ_VIRT ; } +static inline bool crypto_tfm_req_seg (struct crypto_tfm *tfm) +{ +return tfm->__crt_alg->cra_flags &CRYPTO_ALG_REQ_SEG ; +} +static inline u32 crypto_request_flags (struct crypto_async_request *req) {return req->flags & ~CRYPTO_TFM_REQ_ON_STACK ;
include/crypto/internal/acompress.h +10 -0
@@ -154,6 +154,11 @@ static inline bool acomp_request_issg(struct acomp_req *req) CRYPTO_ACOMP_REQ_DST_VIRT)); } +static inline bool acomp_request_isunit (struct acomp_req *req) +{ +return req->base.flags &CRYPTO_ACOMP_REQ_SRC_SEG ; +} +static inline bool acomp_request_src_isvirt (struct acomp_req *req) {return req->base.flags &CRYPTO_ACOMP_REQ_SRC_VIRT ;
@@ -191,6 +196,11 @@ static inline bool crypto_acomp_req_virt(struct crypto_acomp *tfm)return crypto_tfm_req_virt (&tfm->base); } +static inline bool crypto_acomp_req_seg (struct crypto_acomp *tfm) +{ +return crypto_tfm_req_seg (&tfm->base); +} +void crypto_acomp_free_streams (struct crypto_acomp_streams *s);int crypto_acomp_alloc_streams (struct crypto_acomp_streams *s);
include/linux/crypto.h +3 -0
@@ -136,6 +136,9 @@/* Set if the algorithm supports virtual addresses. */ #define CRYPTO_ALG_REQ_VIRT 0x00040000 +/* Set if the algorithm supports segmentation (implies REQ_VIRT). */ +#define CRYPTO_ALG_REQ_SEG 0x00080000 +/* The high bits 0xff000000 are reserved for type-specific flags. */ /*
Signature · 1 line
2.39.5
Herbert Xu
maintainerPATCH 4/4 crypto: testmgr - Add multibuffer acomp testing
In reply to Herbert XuAdd rudimentary multibuffer acomp testing. Testing coverage is extended to compression vectors only.
--- crypto/testmgr.c | 145 +++++++++++++++++++++++------------------------ 1 file changed, 72 insertions(+), 73 deletions(-)
crypto/testmgr.c +72 -73
@@ -58,6 +58,9 @@ module_param(fuzz_iterations, uint, 0644);MODULE_PARM_DESC (fuzz_iterations,"number of fuzz test iterations" );#endif +/* Multibuffer is unlimited. Set arbitrary limit for testing. */ +#define MAX_MB_MSGS 16 +#ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS /* a perfect nop */
@@ -3326,14 +3329,19 @@ static int test_acomp(struct crypto_acomp *tfm, int ctcount, int dtcount) {const char *algo =crypto_tfm_alg_driver_name (crypto_acomp_tfm (tfm)); -unsigned int i; +struct scatterlist src[MAX_MB_MSGS ], dst[2 ]; +ACOMP_REQUEST_ON_STACK (req, tfm);char *output, *decomp_out; -int ret; -struct scatterlist src, dst; -struct acomp_req *req;struct crypto_wait wait; +int ret = -ENOMEM ; +unsigned int i; - output =kmalloc (COMP_BUF_SIZE ,GFP_KERNEL ); +acomp_request_set_callback (req, +CRYPTO_TFM_REQ_MAY_SLEEP | +CRYPTO_TFM_REQ_MAY_BACKLOG , +NULL ,NULL ); + + output =kmalloc (PAGE_SIZE ,GFP_KERNEL );if (!output)return -ENOMEM ;
@@ -3346,7 +3354,9 @@ static int test_acomp(struct crypto_acomp *tfm,for (i =0 ; i < ctcount; i++) {unsigned int dlen =COMP_BUF_SIZE ;int ilen = ctemplate[i].inlen; +struct scatterlist *sg;void *input_vec; +int j; input_vec =kmemdup (ctemplate[i].input, ilen,GFP_KERNEL );if (!input_vec) {
@@ -3354,70 +3364,74 @@ static int test_acomp(struct crypto_acomp *tfm, goto out; } -memset (output,0 , dlen);crypto_init_wait (&wait); -sg_init_one (&src, input_vec, ilen); -sg_init_one (&dst, output, dlen); - req =acomp_request_alloc (tfm); -if (!req) { -pr_err ("alg: acomp: request alloc failed for %s\n" , - algo); -kfree (input_vec); - ret = -ENOMEM ; - goto out; +sg_init_table (src,MAX_MB_MSGS ); +for (j =0 ; j <MAX_MB_MSGS ; j++) +sg_set_buf (src + j, input_vec, ilen); + +sg_init_one (dst, output,PAGE_SIZE ); +acomp_request_set_src_unit (req, src,MAX_MB_MSGS * ilen, + dst, ilen); + + ret =crypto_acomp_compress (req); +if (ret == -EAGAIN ) { + req =ACOMP_REQUEST_CLONE (req,GFP_KERNEL ); +acomp_request_set_callback (req, +CRYPTO_TFM_REQ_MAY_SLEEP | +CRYPTO_TFM_REQ_MAY_BACKLOG , + crypto_req_done, &wait); + ret =crypto_acomp_compress (req); + ret =crypto_wait_req (ret, &wait); } - -acomp_request_set_params (req, &src, &dst, ilen, dlen); -acomp_request_set_callback (req,CRYPTO_TFM_REQ_MAY_BACKLOG , - crypto_req_done, &wait); - - ret =crypto_wait_req (crypto_acomp_compress (req), &wait);if (ret) {pr_err ("alg: acomp: compression failed on test %d for %s: ret=%d\n" , i +1 , algo, -ret);kfree (input_vec); -acomp_request_free (req); goto out; } - ilen = req->dlen; + sg = dst; + ilen = sg->length; dlen =COMP_BUF_SIZE ; -sg_init_one (&src, output, ilen); -sg_init_one (&dst, decomp_out, dlen); -crypto_init_wait (&wait); -acomp_request_set_params (req, &src, &dst, ilen, dlen); +for (j =0 ; j <MAX_MB_MSGS ; j++) { +sg_init_one (src, decomp_out, dlen); +acomp_request_set_params (req, sg, src, ilen, dlen); +crypto_init_wait (&wait); + ret =crypto_wait_req (crypto_acomp_decompress (req), &wait); +if (ret) { +pr_err ("alg: acomp: re-decompression failed on test %d (%d) for %s: ret=%d\n" , + i +1 , j, algo, -ret); +acomp_free_sgl (dst); +kfree (input_vec); + goto out; + } - ret =crypto_wait_req (crypto_acomp_decompress (req), &wait); -if (ret) { -pr_err ("alg: acomp: compression failed on test %d for %s: ret=%d\n" , - i +1 , algo, -ret); -kfree (input_vec); -acomp_request_free (req); - goto out; - } - -if (req->dlen != ctemplate[i].inlen) { -pr_err ("alg: acomp: Compression test %d failed for %s: output len = %d\n" , - i +1 , algo, req->dlen); - ret = -EINVAL ; -kfree (input_vec); -acomp_request_free (req); - goto out; - } - -if (memcmp (input_vec, decomp_out, req->dlen)) { -pr_err ("alg: acomp: Compression test %d failed for %s\n" , - i +1 , algo); -hexdump (output, req->dlen); - ret = -EINVAL ; -kfree (input_vec); -acomp_request_free (req); - goto out; +if (req->dlen != ctemplate[i].inlen) { +pr_err ("alg: acomp: Compression test %d (%d) failed for %s: output len = %d\n" , + i +1 , j, algo, req->dlen); + ret = -EINVAL ; +acomp_free_sgl (dst); +kfree (input_vec); + goto out; + } + +if (memcmp (input_vec, decomp_out, req->dlen)) { +pr_err ("alg: acomp: Compression test %d (%d) failed for %s\n" , + i +1 , j, algo); +hexdump (output, req->dlen); + ret = -EINVAL ; +acomp_free_sgl (dst); +kfree (input_vec); + goto out; + } +if (acomp_sgl_split (sg)) + sg =sg_next (sg); + sg =sg_next (sg); } +acomp_free_sgl (dst);kfree (input_vec); -acomp_request_free (req); }for (i =0 ; i < dtcount; i++) {
@@ -3431,30 +3445,17 @@ static int test_acomp(struct crypto_acomp *tfm, goto out; } -memset (output,0 , dlen);crypto_init_wait (&wait); -sg_init_one (&src, input_vec, ilen); -sg_init_one (&dst, output, dlen); +sg_init_one (src, input_vec, ilen); +sg_init_one (dst, output, dlen); - req =acomp_request_alloc (tfm); -if (!req) { -pr_err ("alg: acomp: request alloc failed for %s\n" , - algo); -kfree (input_vec); - ret = -ENOMEM ; - goto out; - } - -acomp_request_set_params (req, &src, &dst, ilen, dlen); -acomp_request_set_callback (req,CRYPTO_TFM_REQ_MAY_BACKLOG , - crypto_req_done, &wait); +acomp_request_set_params (req, src, dst, ilen, dlen); ret =crypto_wait_req (crypto_acomp_decompress (req), &wait);if (ret) {pr_err ("alg: acomp: decompression failed on test %d for %s: ret=%d\n" , i +1 , algo, -ret);kfree (input_vec); -acomp_request_free (req); goto out; }
@@ -3463,7 +3464,6 @@ static int test_acomp(struct crypto_acomp *tfm, i + 1, algo, req->dlen); ret = -EINVAL ;kfree (input_vec); -acomp_request_free (req); goto out; }
@@ -3473,17 +3473,16 @@ static int test_acomp(struct crypto_acomp *tfm,hexdump (output, req->dlen); ret = -EINVAL ;kfree (input_vec); -acomp_request_free (req); goto out; }kfree (input_vec); -acomp_request_free (req); } ret =0 ; out: +acomp_request_free (req);kfree (decomp_out);kfree (output);return ret;
Signature · 1 line
2.39.5