lkml.org 
[lkml]   [2024]   [Mar]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] crypto: rockchip/rk3288 - Add dereference of NULL pointer check
Date
In rk_crypto_probe() crypto_engine_alloc_init() is assigned to
crypto_info->engine and there is a dereference of it in
clk_mt2712_top_init_early() which could lead to a NULL pointer
dereference on failure of crypto_engine_alloc_init().

Fix this bug by adding a check of crypto_info->engine.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 57d67c6e8219 ("crypto: rockchip - rework by using crypto_engine")

Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru>
---
drivers/crypto/rockchip/rk3288_crypto.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/crypto/rockchip/rk3288_crypto.c b/drivers/crypto/rockchip/rk3288_crypto.c
index 70edf40bc523..88cea1e36afa 100644
--- a/drivers/crypto/rockchip/rk3288_crypto.c
+++ b/drivers/crypto/rockchip/rk3288_crypto.c
@@ -371,6 +371,10 @@ static int rk_crypto_probe(struct platform_device *pdev)
}

crypto_info->engine = crypto_engine_alloc_init(&pdev->dev, true);
+ if (!crypto_info->engine) {
+ dev_err(&pdev->dev, "memory allocation failed.\n");
+ goto err_crypto;
+ }
crypto_engine_start(crypto_info->engine);
init_completion(&crypto_info->complete);

--
2.30.2

\
 
 \ /
  Last update: 2024-05-27 15:33    [W:0.017 / U:0.360 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site