[bsp]Fixed a stack overflow bug in drv_crypto.c

Added if null before used.
This commit is contained in:
David Lin 2020-03-14 23:11:37 +08:00 committed by GitHub
parent 891e4794c0
commit 45ae555a0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -168,6 +168,11 @@ static rt_err_t _crypto_create(struct rt_hwcrypto_ctx *ctx)
case HWCRYPTO_TYPE_RNG:
{
RNG_HandleTypeDef *hrng = rt_calloc(1, sizeof(RNG_HandleTypeDef));
if (RT_NULL == hrng)
{
res = -RT_ERROR;
break;
}
hrng->Instance = RNG;
HAL_RNG_Init(hrng);