Ver código fonte

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

Added if null before used.
David Lin 6 anos atrás
pai
commit
45ae555a0b
1 arquivos alterados com 5 adições e 0 exclusões
  1. 5 0
      bsp/stm32/libraries/HAL_Drivers/drv_crypto.c

+ 5 - 0
bsp/stm32/libraries/HAL_Drivers/drv_crypto.c

@@ -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);