diff options
author | Kshitiz Varshney <kshitiz.varshney@nxp.com> | 2021-09-19 17:09:53 +0200 |
---|---|---|
committer | Priyanka Jain <priyanka.jain@nxp.com> | 2021-11-09 14:43:24 +0530 |
commit | bd2a4eb977232c7062489251cdb5a36a99757fc1 (patch) | |
tree | 6a19bff40c85cdadf674ef2343a387b43a51ac09 /drivers/crypto/fsl | |
parent | c0e0cf4989d1de847c4b2ce1927ea7a121351801 (diff) | |
download | u-boot-bd2a4eb977232c7062489251cdb5a36a99757fc1.zip u-boot-bd2a4eb977232c7062489251cdb5a36a99757fc1.tar.gz u-boot-bd2a4eb977232c7062489251cdb5a36a99757fc1.tar.bz2 |
board: fsl_validate: Fix Double free Issue
Remove Double free issue from calc_img_key_hash() and
calc_esbchdr_esbc_hash() function.
Verified the secure boot changes using lx2162aqds board.
Signed-off-by: Kshitiz Varshney <kshitiz.varshney@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
Diffstat (limited to 'drivers/crypto/fsl')
-rw-r--r-- | drivers/crypto/fsl/fsl_hash.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/crypto/fsl/fsl_hash.c b/drivers/crypto/fsl/fsl_hash.c index 8b5c26d..8039473 100644 --- a/drivers/crypto/fsl/fsl_hash.c +++ b/drivers/crypto/fsl/fsl_hash.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ /* * Copyright 2014 Freescale Semiconductor, Inc. - * + * Copyright 2021 NXP */ #include <common.h> @@ -120,8 +120,8 @@ static int caam_hash_update(void *hash_ctx, const void *buf, * Perform progressive hashing on the given buffer and copy hash at * destination buffer * - * The context is freed after completion of hash operation. - * + * The context is freed after successful completion of hash operation. + * In case of failure, context is not freed. * @hash_ctx: Pointer to the context for hashing * @dest_buf: Pointer to the destination buffer where hash is to be copied * @size: Size of the buffer being hashed @@ -136,7 +136,6 @@ static int caam_hash_finish(void *hash_ctx, void *dest_buf, int i = 0, ret = 0; if (size < driver_hash[caam_algo].digestsize) { - free(ctx); return -EINVAL; } @@ -152,11 +151,12 @@ static int caam_hash_finish(void *hash_ctx, void *dest_buf, ret = run_descriptor_jr(ctx->sha_desc); - if (ret) + if (ret) { debug("Error %x\n", ret); - else + return ret; + } else { memcpy(dest_buf, ctx->hash, sizeof(ctx->hash)); - + } free(ctx); return ret; } |