[dpdk-dev] [dpdk-stable] [PATCH v3] crypto/qat: fix uninitilized compiler warning
Ferruh Yigit
ferruh.yigit at intel.com
Wed May 19 10:11:52 CEST 2021
On 5/17/2021 10:07 AM, Feifei Wang wrote:
> In Arm platform, when "RTE_ARCH_ARM64_MEMCPY" is set as true, compiler
> will report variable uninitilized warning:
>
> ../drivers/crypto/qat/qat_sym_session.c:
> In function ‘partial_hash_compute’:
> ../lib/eal/include/generic/rte_byteorder.h:241:24: warning:
> ‘<U35a0>’ may be used uninitialized in this function
> [-Wmaybe-uninitialized]
> 241 | #define rte_bswap32(x) __builtin_bswap32(x)
> ...
>
> This is because "digest" will be initialized by "rte_memcpy" function
> rather than "memcpy" if "RTE_ARCH_ARM64_MEMCPY" is set as true. However,
How 'digest' is initialized by 'rte_memcpy'?
> compiler cannot know it is initialized by the function.
>
> To fix this, use "calloc" to initialize "digest".
>
> Fixes: cd7fc8a84b48 ("eal/arm64: optimize memcpy")
> Cc: stable at dpdk.org
>
> Signed-off-by: Feifei Wang <feifei.wang2 at arm.com>
> Reviewed-by: Ruifeng Wang <ruifeng.wang at arm.com>
> ---
> v2: add check and free for memory dynamic allocation (David Marchand)
> v3: fix compiler error
>
> drivers/crypto/qat/qat_sym_session.c | 27 ++++++++++++++++++---------
> 1 file changed, 18 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/crypto/qat/qat_sym_session.c b/drivers/crypto/qat/qat_sym_session.c
> index 231b1640da..105a10957a 100644
> --- a/drivers/crypto/qat/qat_sym_session.c
> +++ b/drivers/crypto/qat/qat_sym_session.c
> @@ -1190,8 +1190,7 @@ static int partial_hash_compute(enum icp_qat_hw_auth_algo hash_alg,
> uint8_t *data_out)
> {
> int digest_size;
> - uint8_t digest[qat_hash_get_digest_size(
> - ICP_QAT_HW_AUTH_ALGO_DELIMITER)];
> + uint8_t *digest;
Will a memset 'digest' work too? Although not sure which one is better.
More information about the dev
mailing list