Skip to content

Commit 019d62d

Browse files
horiagherbertx
authored andcommitted
crypto: caam - fix gfp allocation flags (part II)
This is the 2nd part of fixing the usage of GFP_KERNEL for memory allocations, taking care off all the places that haven't caused a real problem / failure. Again, the issue being fixed is that GFP_KERNEL should be used only when MAY_SLEEP flag is set, i.e. MAY_BACKLOG flag usage is orthogonal. Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 42cfcaf commit 019d62d

4 files changed

Lines changed: 25 additions & 28 deletions

File tree

‎drivers/crypto/caam/caamalg.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,8 +1187,8 @@ static struct aead_edesc *aead_edesc_alloc(struct aead_request *req,
11871187
struct crypto_aead *aead = crypto_aead_reqtfm(req);
11881188
struct caam_ctx *ctx = crypto_aead_ctx(aead);
11891189
struct device *jrdev = ctx->jrdev;
1190-
gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG |
1191-
CRYPTO_TFM_REQ_MAY_SLEEP)) ? GFP_KERNEL : GFP_ATOMIC;
1190+
gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
1191+
GFP_KERNEL : GFP_ATOMIC;
11921192
int src_nents, mapped_src_nents, dst_nents = 0, mapped_dst_nents = 0;
11931193
struct aead_edesc *edesc;
11941194
int sec4_sg_index, sec4_sg_len, sec4_sg_bytes;
@@ -1680,8 +1680,7 @@ static struct ablkcipher_edesc *ablkcipher_giv_edesc_alloc(
16801680
struct crypto_ablkcipher *ablkcipher = crypto_ablkcipher_reqtfm(req);
16811681
struct caam_ctx *ctx = crypto_ablkcipher_ctx(ablkcipher);
16821682
struct device *jrdev = ctx->jrdev;
1683-
gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG |
1684-
CRYPTO_TFM_REQ_MAY_SLEEP)) ?
1683+
gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
16851684
GFP_KERNEL : GFP_ATOMIC;
16861685
int src_nents, mapped_src_nents, dst_nents, mapped_dst_nents;
16871686
struct ablkcipher_edesc *edesc;

‎drivers/crypto/caam/caamalg_qi.c‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,8 @@ static struct aead_edesc *aead_edesc_alloc(struct aead_request *req,
555555
struct caam_aead_alg *alg = container_of(crypto_aead_alg(aead),
556556
typeof(*alg), aead);
557557
struct device *qidev = ctx->qidev;
558-
gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG |
559-
CRYPTO_TFM_REQ_MAY_SLEEP)) ? GFP_KERNEL : GFP_ATOMIC;
558+
gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
559+
GFP_KERNEL : GFP_ATOMIC;
560560
int src_nents, mapped_src_nents, dst_nents = 0, mapped_dst_nents = 0;
561561
struct aead_edesc *edesc;
562562
dma_addr_t qm_sg_dma, iv_dma = 0;
@@ -808,8 +808,7 @@ static struct ablkcipher_edesc *ablkcipher_edesc_alloc(struct ablkcipher_request
808808
struct crypto_ablkcipher *ablkcipher = crypto_ablkcipher_reqtfm(req);
809809
struct caam_ctx *ctx = crypto_ablkcipher_ctx(ablkcipher);
810810
struct device *qidev = ctx->qidev;
811-
gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG |
812-
CRYPTO_TFM_REQ_MAY_SLEEP)) ?
811+
gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
813812
GFP_KERNEL : GFP_ATOMIC;
814813
int src_nents, mapped_src_nents, dst_nents = 0, mapped_dst_nents = 0;
815814
struct ablkcipher_edesc *edesc;
@@ -953,8 +952,7 @@ static struct ablkcipher_edesc *ablkcipher_giv_edesc_alloc(
953952
struct crypto_ablkcipher *ablkcipher = crypto_ablkcipher_reqtfm(req);
954953
struct caam_ctx *ctx = crypto_ablkcipher_ctx(ablkcipher);
955954
struct device *qidev = ctx->qidev;
956-
gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG |
957-
CRYPTO_TFM_REQ_MAY_SLEEP)) ?
955+
gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
958956
GFP_KERNEL : GFP_ATOMIC;
959957
int src_nents, mapped_src_nents, dst_nents, mapped_dst_nents;
960958
struct ablkcipher_edesc *edesc;

‎drivers/crypto/caam/caamhash.c‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -719,8 +719,8 @@ static int ahash_update_ctx(struct ahash_request *req)
719719
struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
720720
struct caam_hash_state *state = ahash_request_ctx(req);
721721
struct device *jrdev = ctx->jrdev;
722-
gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG |
723-
CRYPTO_TFM_REQ_MAY_SLEEP)) ? GFP_KERNEL : GFP_ATOMIC;
722+
gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
723+
GFP_KERNEL : GFP_ATOMIC;
724724
u8 *buf = current_buf(state);
725725
int *buflen = current_buflen(state);
726726
u8 *next_buf = alt_buf(state);
@@ -849,8 +849,8 @@ static int ahash_final_ctx(struct ahash_request *req)
849849
struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
850850
struct caam_hash_state *state = ahash_request_ctx(req);
851851
struct device *jrdev = ctx->jrdev;
852-
gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG |
853-
CRYPTO_TFM_REQ_MAY_SLEEP)) ? GFP_KERNEL : GFP_ATOMIC;
852+
gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
853+
GFP_KERNEL : GFP_ATOMIC;
854854
int buflen = *current_buflen(state);
855855
u32 *desc;
856856
int sec4_sg_bytes, sec4_sg_src_index;
@@ -926,8 +926,8 @@ static int ahash_finup_ctx(struct ahash_request *req)
926926
struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
927927
struct caam_hash_state *state = ahash_request_ctx(req);
928928
struct device *jrdev = ctx->jrdev;
929-
gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG |
930-
CRYPTO_TFM_REQ_MAY_SLEEP)) ? GFP_KERNEL : GFP_ATOMIC;
929+
gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
930+
GFP_KERNEL : GFP_ATOMIC;
931931
int buflen = *current_buflen(state);
932932
u32 *desc;
933933
int sec4_sg_src_index;
@@ -1013,8 +1013,8 @@ static int ahash_digest(struct ahash_request *req)
10131013
struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
10141014
struct caam_hash_state *state = ahash_request_ctx(req);
10151015
struct device *jrdev = ctx->jrdev;
1016-
gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG |
1017-
CRYPTO_TFM_REQ_MAY_SLEEP)) ? GFP_KERNEL : GFP_ATOMIC;
1016+
gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
1017+
GFP_KERNEL : GFP_ATOMIC;
10181018
u32 *desc;
10191019
int digestsize = crypto_ahash_digestsize(ahash);
10201020
int src_nents, mapped_nents;
@@ -1093,8 +1093,8 @@ static int ahash_final_no_ctx(struct ahash_request *req)
10931093
struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
10941094
struct caam_hash_state *state = ahash_request_ctx(req);
10951095
struct device *jrdev = ctx->jrdev;
1096-
gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG |
1097-
CRYPTO_TFM_REQ_MAY_SLEEP)) ? GFP_KERNEL : GFP_ATOMIC;
1096+
gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
1097+
GFP_KERNEL : GFP_ATOMIC;
10981098
u8 *buf = current_buf(state);
10991099
int buflen = *current_buflen(state);
11001100
u32 *desc;
@@ -1154,8 +1154,8 @@ static int ahash_update_no_ctx(struct ahash_request *req)
11541154
struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
11551155
struct caam_hash_state *state = ahash_request_ctx(req);
11561156
struct device *jrdev = ctx->jrdev;
1157-
gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG |
1158-
CRYPTO_TFM_REQ_MAY_SLEEP)) ? GFP_KERNEL : GFP_ATOMIC;
1157+
gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
1158+
GFP_KERNEL : GFP_ATOMIC;
11591159
u8 *buf = current_buf(state);
11601160
int *buflen = current_buflen(state);
11611161
u8 *next_buf = alt_buf(state);
@@ -1280,8 +1280,8 @@ static int ahash_finup_no_ctx(struct ahash_request *req)
12801280
struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
12811281
struct caam_hash_state *state = ahash_request_ctx(req);
12821282
struct device *jrdev = ctx->jrdev;
1283-
gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG |
1284-
CRYPTO_TFM_REQ_MAY_SLEEP)) ? GFP_KERNEL : GFP_ATOMIC;
1283+
gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
1284+
GFP_KERNEL : GFP_ATOMIC;
12851285
int buflen = *current_buflen(state);
12861286
u32 *desc;
12871287
int sec4_sg_bytes, sec4_sg_src_index, src_nents, mapped_nents;
@@ -1370,8 +1370,8 @@ static int ahash_update_first(struct ahash_request *req)
13701370
struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
13711371
struct caam_hash_state *state = ahash_request_ctx(req);
13721372
struct device *jrdev = ctx->jrdev;
1373-
gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG |
1374-
CRYPTO_TFM_REQ_MAY_SLEEP)) ? GFP_KERNEL : GFP_ATOMIC;
1373+
gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
1374+
GFP_KERNEL : GFP_ATOMIC;
13751375
u8 *next_buf = alt_buf(state);
13761376
int *next_buflen = alt_buflen(state);
13771377
int to_hash;

‎drivers/crypto/caam/caampkc.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ static struct rsa_edesc *rsa_edesc_alloc(struct akcipher_request *req,
9797
struct caam_rsa_ctx *ctx = akcipher_tfm_ctx(tfm);
9898
struct device *dev = ctx->dev;
9999
struct rsa_edesc *edesc;
100-
gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG |
101-
CRYPTO_TFM_REQ_MAY_SLEEP)) ? GFP_KERNEL : GFP_ATOMIC;
100+
gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
101+
GFP_KERNEL : GFP_ATOMIC;
102102
int sgc;
103103
int sec4_sg_index, sec4_sg_len = 0, sec4_sg_bytes;
104104
int src_nents, dst_nents;

0 commit comments

Comments
 (0)