All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aleksandr Mishin <amishin@t-argos.ru>
To: Corentin Labbe <clabbe@baylibre.com>
Cc: Aleksandr Mishin <amishin@t-argos.ru>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S . Miller" <davem@davemloft.net>,
	Heiko Stuebner <heiko@sntech.de>, <linux-crypto@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-rockchip@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <lvc-project@linuxtesting.org>
Subject: [PATCH] crypto: rockchip/rk3288 - Add dereference of NULL pointer check
Date: Mon, 4 Mar 2024 15:20:31 +0300	[thread overview]
Message-ID: <20240304122031.25325-1-amishin@t-argos.ru> (raw)

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


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

WARNING: multiple messages have this Message-ID (diff)
From: Aleksandr Mishin <amishin@t-argos.ru>
To: Corentin Labbe <clabbe@baylibre.com>
Cc: Aleksandr Mishin <amishin@t-argos.ru>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S . Miller" <davem@davemloft.net>,
	Heiko Stuebner <heiko@sntech.de>, <linux-crypto@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-rockchip@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <lvc-project@linuxtesting.org>
Subject: [PATCH] crypto: rockchip/rk3288 - Add dereference of NULL pointer check
Date: Mon, 4 Mar 2024 15:20:31 +0300	[thread overview]
Message-ID: <20240304122031.25325-1-amishin@t-argos.ru> (raw)

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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Aleksandr Mishin <amishin@t-argos.ru>
To: Corentin Labbe <clabbe@baylibre.com>
Cc: Aleksandr Mishin <amishin@t-argos.ru>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S . Miller" <davem@davemloft.net>,
	Heiko Stuebner <heiko@sntech.de>, <linux-crypto@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-rockchip@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <lvc-project@linuxtesting.org>
Subject: [PATCH] crypto: rockchip/rk3288 - Add dereference of NULL pointer check
Date: Mon, 4 Mar 2024 15:20:31 +0300	[thread overview]
Message-ID: <20240304122031.25325-1-amishin@t-argos.ru> (raw)

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


             reply	other threads:[~2024-03-04 12:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-04 12:20 Aleksandr Mishin [this message]
2024-03-04 12:20 ` [PATCH] crypto: rockchip/rk3288 - Add dereference of NULL pointer check Aleksandr Mishin
2024-03-04 12:20 ` Aleksandr Mishin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240304122031.25325-1-amishin@t-argos.ru \
    --to=amishin@t-argos.ru \
    --cc=clabbe@baylibre.com \
    --cc=davem@davemloft.net \
    --cc=heiko@sntech.de \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=lvc-project@linuxtesting.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.