[PATCH] crypto: rockchip/rk3288 - Add dereference of NULL pointer check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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





[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux