Skip to content

Commit c4e9065

Browse files
chunkeeyherbertx
authored andcommitted
crypto: crypto4xx - avoid VLA use
This patch fixes some of the -Wvla warnings. crypto4xx_alg.c:83:19: warning: Variable length array is used. crypto4xx_alg.c:273:56: warning: Variable length array is used. crypto4xx_alg.c:380:32: warning: Variable length array is used. Signed-off-by: Christian Lamparter <chunkeey@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent ce05ffe commit c4e9065

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

‎drivers/crypto/amcc/crypto4xx_alg.c‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static inline int crypto4xx_crypt(struct skcipher_request *req,
8080
{
8181
struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(req);
8282
struct crypto4xx_ctx *ctx = crypto_skcipher_ctx(cipher);
83-
__le32 iv[ivlen];
83+
__le32 iv[AES_IV_SIZE];
8484

8585
if (ivlen)
8686
crypto4xx_memcpy_to_le32(iv, req->iv, ivlen);
@@ -270,13 +270,7 @@ static inline bool crypto4xx_aead_need_fallback(struct aead_request *req,
270270
static int crypto4xx_aead_fallback(struct aead_request *req,
271271
struct crypto4xx_ctx *ctx, bool do_decrypt)
272272
{
273-
char aead_req_data[sizeof(struct aead_request) +
274-
crypto_aead_reqsize(ctx->sw_cipher.aead)]
275-
__aligned(__alignof__(struct aead_request));
276-
277-
struct aead_request *subreq = (void *) aead_req_data;
278-
279-
memset(subreq, 0, sizeof(aead_req_data));
273+
struct aead_request *subreq = aead_request_ctx(req);
280274

281275
aead_request_set_tfm(subreq, ctx->sw_cipher.aead);
282276
aead_request_set_callback(subreq, req->base.flags,
@@ -377,7 +371,7 @@ static int crypto4xx_crypt_aes_ccm(struct aead_request *req, bool decrypt)
377371
struct crypto_aead *aead = crypto_aead_reqtfm(req);
378372
unsigned int len = req->cryptlen;
379373
__le32 iv[16];
380-
u32 tmp_sa[ctx->sa_len * 4];
374+
u32 tmp_sa[SA_AES128_CCM_LEN + 4];
381375
struct dynamic_sa_ctl *sa = (struct dynamic_sa_ctl *)tmp_sa;
382376

383377
if (crypto4xx_aead_need_fallback(req, true, decrypt))
@@ -386,7 +380,7 @@ static int crypto4xx_crypt_aes_ccm(struct aead_request *req, bool decrypt)
386380
if (decrypt)
387381
len -= crypto_aead_authsize(aead);
388382

389-
memcpy(tmp_sa, decrypt ? ctx->sa_in : ctx->sa_out, sizeof(tmp_sa));
383+
memcpy(tmp_sa, decrypt ? ctx->sa_in : ctx->sa_out, ctx->sa_len * 4);
390384
sa->sa_command_0.bf.digest_len = crypto_aead_authsize(aead) >> 2;
391385

392386
if (req->iv[0] == 1) {

0 commit comments

Comments
 (0)