diff options
author | Behan Webster <behanw@converseincode.com> | 2014-04-04 17:18:00 -0400 |
---|---|---|
committer | Behan Webster <behanw@converseincode.com> | 2014-10-14 04:51:23 -0400 |
commit | ce1f3e47d9d11ffde75d06170304dc9ff2afe0c6 (patch) | |
tree | 4d86fc571aaea82055c38f86041bec462281c38d | |
parent | 7128470f6b21b922b42f790d429330562eb6eab1 (diff) |
crypto: LLVMLinux: Remove VLAIS from crypto/n2_core.c
Replaced the use of a Variable Length Array In Struct (VLAIS) with a C99
compliant equivalent. This patch allocates the appropriate amount of memory
using a char array using the SHASH_DESC_ON_STACK macro.
The new code can be compiled with both gcc and clang.
Signed-off-by: Behan Webster <behanw@converseincode.com>
Reviewed-by: Mark Charlebois <charlebm@gmail.com>
Reviewed-by: Jan-Simon Möller <dl9pf@gmx.de>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | drivers/crypto/n2_core.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/crypto/n2_core.c b/drivers/crypto/n2_core.c index 7263c10a56ee..f8e3207fecb1 100644 --- a/drivers/crypto/n2_core.c +++ b/drivers/crypto/n2_core.c | |||
@@ -445,10 +445,7 @@ static int n2_hmac_async_setkey(struct crypto_ahash *tfm, const u8 *key, | |||
445 | struct n2_hmac_ctx *ctx = crypto_ahash_ctx(tfm); | 445 | struct n2_hmac_ctx *ctx = crypto_ahash_ctx(tfm); |
446 | struct crypto_shash *child_shash = ctx->child_shash; | 446 | struct crypto_shash *child_shash = ctx->child_shash; |
447 | struct crypto_ahash *fallback_tfm; | 447 | struct crypto_ahash *fallback_tfm; |
448 | struct { | 448 | SHASH_DESC_ON_STACK(shash, child_shash); |
449 | struct shash_desc shash; | ||
450 | char ctx[crypto_shash_descsize(child_shash)]; | ||
451 | } desc; | ||
452 | int err, bs, ds; | 449 | int err, bs, ds; |
453 | 450 | ||
454 | fallback_tfm = ctx->base.fallback_tfm; | 451 | fallback_tfm = ctx->base.fallback_tfm; |
@@ -456,15 +453,15 @@ static int n2_hmac_async_setkey(struct crypto_ahash *tfm, const u8 *key, | |||
456 | if (err) | 453 | if (err) |
457 | return err; | 454 | return err; |
458 | 455 | ||
459 | desc.shash.tfm = child_shash; | 456 | shash->tfm = child_shash; |
460 | desc.shash.flags = crypto_ahash_get_flags(tfm) & | 457 | shash->flags = crypto_ahash_get_flags(tfm) & |
461 | CRYPTO_TFM_REQ_MAY_SLEEP; | 458 | CRYPTO_TFM_REQ_MAY_SLEEP; |
462 | 459 | ||
463 | bs = crypto_shash_blocksize(child_shash); | 460 | bs = crypto_shash_blocksize(child_shash); |
464 | ds = crypto_shash_digestsize(child_shash); | 461 | ds = crypto_shash_digestsize(child_shash); |
465 | BUG_ON(ds > N2_HASH_KEY_MAX); | 462 | BUG_ON(ds > N2_HASH_KEY_MAX); |
466 | if (keylen > bs) { | 463 | if (keylen > bs) { |
467 | err = crypto_shash_digest(&desc.shash, key, keylen, | 464 | err = crypto_shash_digest(shash, key, keylen, |
468 | ctx->hash_key); | 465 | ctx->hash_key); |
469 | if (err) | 466 | if (err) |
470 | return err; | 467 | return err; |