ARM Sunxi Platform Development
 help / color / mirror / Atom feed
* [PATCH 00/12] crypto: Remove redundant error messages on IRQ request failure
@ 2026-07-17  8:00 Pan Chuang
  2026-07-17  8:00 ` [PATCH 01/12] crypto: allwinner - Remove redundant dev_err() Pan Chuang
  0 siblings, 1 reply; 3+ messages in thread
From: Pan Chuang @ 2026-07-17  8:00 UTC (permalink / raw)
  To: Corentin Labbe, Herbert Xu, David S. Miller, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Neal Liu, Joel Stanley,
	Andrew Jeffery, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Horia Geantă, Pankaj Gupta, Gaurav Jain, Gilad Ben-Yossef,
	Hans Ulli Kroll, Linus Walleij, Antoine Tenart, Prabhjot Khurana,
	Declan Murphy, Srujana Challa, Bharat Bhushan, Frank Li,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Heiko Stuebner, Maxime Coquelin, Alexandre Torgue, Ovidiu Panait,
	Arnd Bergmann, Eric Biggers, Pan Chuang, Myeonghun Pak, Ijae Kim,
	Krzysztof Kozlowski, Kees Cook, Thorsten Blum, Colin Ian King,
	Sakari Ailus, open list:ALLWINNER CRYPTO DRIVERS,
	moderated list:ARM/Allwinner sunXi SoC support,
	open list:ARM/Allwinner sunXi SoC support, open list,
	open list:ARM/Amlogic Meson SoC Crypto Drivers,
	moderated list:ASPEED CRYPTO DRIVER,
	open list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	open list:ARM/Rockchip SoC support,
	moderated list:ARM/STM32 ARCHITECTURE

Commit 55b48e23f5c4 ("genirq/devres: Add error handling in
devm_request_*_irq()") added automatic error logging to
devm_request_threaded_irq() and devm_request_any_context_irq()
via the new devm_request_result() helper, which prints device
name, IRQ number, handler functions, and error code on failure.

Since devm_request_irq() is a static inline wrapper around
devm_request_threaded_irq(), it also benefits from this
automatic logging.

Remove the now-redundant dev_err() and dev_err_probe() calls
in crypto drivers that follow these devm_request_*_irq()
functions, as the core now provides more detailed diagnostic
information on failure.

Pan Chuang (12):
  crypto: allwinner - Remove redundant dev_err()
  crypto: amlogic - Remove redundant dev_err()
  crypto: aspeed - Remove redundant dev_err()
  crypto: Remove redundant dev_err()/dev_err_probe()
  crypto: caam - Remove redundant dev_err()
  crypto: ccree - Remove redundant dev_err()
  crypto: sl3516 - Remove redundant dev_err()
  crypto: safexcel - Remove redundant dev_err()
  crypto: keembay - Remove redundant dev_err()
  crypto: octeontx2 - Remove redundant dev_err()
  crypto: rockchip - Remove redundant dev_err()
  crypto: stm32 - Remove redundant dev_err()

 drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c   | 4 +---
 drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c   | 4 +---
 drivers/crypto/amlogic/amlogic-gxl-core.c           | 4 +---
 drivers/crypto/aspeed/aspeed-acry.c                 | 4 +---
 drivers/crypto/aspeed/aspeed-hace.c                 | 4 +---
 drivers/crypto/atmel-aes.c                          | 4 +---
 drivers/crypto/atmel-sha.c                          | 4 +---
 drivers/crypto/atmel-tdes.c                         | 4 +---
 drivers/crypto/caam/jr.c                            | 2 --
 drivers/crypto/ccree/cc_driver.c                    | 4 +---
 drivers/crypto/gemini/sl3516-ce-core.c              | 4 +---
 drivers/crypto/img-hash.c                           | 4 +---
 drivers/crypto/inside-secure/safexcel.c             | 4 +---
 drivers/crypto/intel/keembay/keembay-ocs-aes-core.c | 4 +---
 drivers/crypto/intel/keembay/keembay-ocs-ecc.c      | 4 +---
 drivers/crypto/intel/keembay/keembay-ocs-hcu-core.c | 4 +---
 drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c  | 5 +----
 drivers/crypto/mxs-dcp.c                            | 8 ++------
 drivers/crypto/omap-aes.c                           | 4 +---
 drivers/crypto/omap-des.c                           | 4 +---
 drivers/crypto/omap-sham.c                          | 5 +----
 drivers/crypto/rockchip/rk3288_crypto.c             | 4 +---
 drivers/crypto/sahara.c                             | 3 +--
 drivers/crypto/stm32/stm32-cryp.c                   | 4 +---
 drivers/crypto/stm32/stm32-hash.c                   | 4 +---
 25 files changed, 25 insertions(+), 78 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 01/12] crypto: allwinner - Remove redundant dev_err()
  2026-07-17  8:00 [PATCH 00/12] crypto: Remove redundant error messages on IRQ request failure Pan Chuang
@ 2026-07-17  8:00 ` Pan Chuang
  2026-07-17  8:13   ` sashiko-bot
  0 siblings, 1 reply; 3+ messages in thread
From: Pan Chuang @ 2026-07-17  8:00 UTC (permalink / raw)
  To: Corentin Labbe, Herbert Xu, David S. Miller, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Ovidiu Panait, Arnd Bergmann,
	Pan Chuang, Eric Biggers, open list:ALLWINNER CRYPTO DRIVERS,
	moderated list:ARM/Allwinner sunXi SoC support,
	open list:ARM/Allwinner sunXi SoC support, open list

Since commit 55b48e23f5c4 ("genirq/devres: Add error handling in
devm_request_*_irq()"), devm_request_irq() automatically logs
detailed error messages on failure. Remove the now-redundant
driver-specific dev_err() calls.

Signed-off-by: Pan Chuang <panchuang@vivo.com>
---
 drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c | 4 +---
 drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c
index c6402e87f8a0..21762bd408e5 100644
--- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c
+++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c
@@ -976,10 +976,8 @@ static int sun8i_ce_probe(struct platform_device *pdev)
 
 	err = devm_request_irq(&pdev->dev, irq, ce_irq_handler, 0,
 			       "sun8i-ce-ns", ce);
-	if (err) {
-		dev_err(ce->dev, "Cannot request CryptoEngine Non-secure IRQ (err=%d)\n", err);
+	if (err)
 		goto error_pm;
-	}
 
 	err = sun8i_ce_register_algs(ce);
 	if (err)
diff --git a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c
index 0b22fcddb882..2167dd9f44c7 100644
--- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c
+++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c
@@ -824,10 +824,8 @@ static int sun8i_ss_probe(struct platform_device *pdev)
 		goto error_pm;
 
 	err = devm_request_irq(&pdev->dev, irq, ss_irq_handler, 0, "sun8i-ss", ss);
-	if (err) {
-		dev_err(ss->dev, "Cannot request SecuritySystem IRQ (err=%d)\n", err);
+	if (err)
 		goto error_irq;
-	}
 
 	err = sun8i_ss_register_algs(ss);
 	if (err)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 01/12] crypto: allwinner - Remove redundant dev_err()
  2026-07-17  8:00 ` [PATCH 01/12] crypto: allwinner - Remove redundant dev_err() Pan Chuang
@ 2026-07-17  8:13   ` sashiko-bot
  0 siblings, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-07-17  8:13 UTC (permalink / raw)
  To: Pan Chuang; +Cc: linux-sunxi

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Uninitialized list dereference (kernel panic) due to ignored TRNG registration failure.
- [High] List corruption and kernel panic due to dangling pointers in global algorithm arrays during failed re-binds.
--

--- Patch [1]: [PATCH 01/12] crypto: allwinner - Remove redundant dev_err() ---
commit 19d9808368b2fa17e987058da2afc72772963840
Author: Pan Chuang <panchuang@vivo.com>
Subject: crypto: allwinner - Remove redundant dev_err()

This patch removes redundant driver-specific dev_err() messages after
devm_request_irq() calls. Since commit 55b48e23f5c4, devm_request_irq()
automatically logs detailed error messages on failure, making these
additional prints unnecessary.

> diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c
> index f3b58ed6aed0d..a1cc59a2ce3f7 100644
> --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c
> +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c
> @@ -1039,10 +1039,8 @@ static int sun8i_ce_probe(struct platform_device *pdev)
>  
>  	err = devm_request_irq(&pdev->dev, irq, ce_irq_handler, 0,
>  			       "sun8i-ce-ns", ce);
> -	if (err) {
> -		dev_err(ce->dev, "Cannot request CryptoEngine Non-secure IRQ (err=%d)\n", err);
> +	if (err)
>  		goto error_pm;
> -	}
>  
>  	err = sun8i_ce_register_algs(ce);
>  	if (err)

[Severity: High]
This is a pre-existing issue, but does probe proceed successfully even if
hardware RNG registration fails?

A bit further down in sun8i_ce_probe() in
drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c, the return value of
sun8i_ce_hwrng_register() is ignored:

#ifdef CONFIG_CRYPTO_DEV_SUN8I_CE_TRNG
	sun8i_ce_hwrng_register(ce);
#endif

If registration fails (e.g., due to a duplicate name via -EEXIST from a
mock device, or sysfs unbind/bind races), probe proceeds. Later, upon
unbinding or module removal, sun8i_ce_remove() unconditionally calls
sun8i_ce_hwrng_unregister() which triggers:

drivers/crypto/allwinner/sun8i-ce/sun8i-ce-trng.c:sun8i_ce_hwrng_unregister() {
    ...
	if (ce->variant->trng == CE_ID_NOTSUPP)
		return;
	hwrng_unregister(&ce->trng);
    ...
}

Because the device was never successfully added to the core list, its
list_head remains zero-initialized (from devm_kzalloc). Calling
hwrng_unregister() executes list_del(), which attempts to dereference the
NULL prev and next pointers, causing an immediate kernel oops.

Could the return value of sun8i_ce_hwrng_register() be checked and handled
appropriately?

[Severity: High]
This is another pre-existing issue, but does sun8i_ce_unregister_algs()
leave dangling pointers in the global ce_algs array?

When algorithms are unregistered, the device instance pointers are not
cleared:

drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c:sun8i_ce_unregister_algs() {
    ...
		case CRYPTO_ALG_TYPE_SKCIPHER:
			dev_info(ce->dev, "Unregister %d %s\n", i,
				 ce_algs[i].alg.skcipher.base.base.cra_name);
			crypto_engine_unregister_skcipher(&ce_algs[i].alg.skcipher);
			break;
    ...
}

If a device is successfully bound and then unbound, these global arrays are
left with dangling pointers to the freed device structure. On a subsequent
probe of the device, if algorithm registration fails partway through (such
as if sun8i_ce_register_algs() fails as seen in the diff context above),
the error path calls the unregister function.

The loop sees the dangling pointers from the previous successful bind and
attempts to call crypto_engine_unregister_skcipher() on them again. This
causes a double-unregister of the same algorithm template, resulting in
list corruption.

Could ce_algs[i].ce be set to NULL after unregistering each algorithm?

> diff --git a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c
> index 59c9bc45ec0f2..c994e023afbc4 100644
> --- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c
> +++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c
> @@ -869,10 +869,8 @@ static int sun8i_ss_probe(struct platform_device *pdev)
>  		goto error_pm;
>  
>  	err = devm_request_irq(&pdev->dev, irq, ss_irq_handler, 0, "sun8i-ss", ss);
> -	if (err) {
> -		dev_err(ss->dev, "Cannot request SecuritySystem IRQ (err=%d)\n", err);
> +	if (err)
>  		goto error_irq;
> -	}
>  
>  	err = sun8i_ss_register_algs(ss);
>  	if (err)

[Severity: High]
This is a pre-existing issue, but similar to the sun8i-ce driver above,
can sun8i_ss_unregister_algs() cause a double-free?

drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c:sun8i_ss_unregister_algs() {
    ...
		case CRYPTO_ALG_TYPE_SKCIPHER:
			dev_info(ss->dev, "Unregister %d %s\n", i,
				 ss_algs[i].alg.skcipher.base.base.cra_name);
			crypto_engine_unregister_skcipher(&ss_algs[i].alg.skcipher);
			break;
    ...
}

Failing to clear ss_algs[i].ss to NULL after unregistering the algorithm
leaves a dangling pointer for future probes, which can lead to list
corruption and a double-free in the crypto core during failed re-binds.

Could ss_algs[i].ss be set to NULL after unregistering each algorithm here
as well?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260717080045.191538-1-panchuang@vivo.com?part=1

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-17  8:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-17  8:00 [PATCH 00/12] crypto: Remove redundant error messages on IRQ request failure Pan Chuang
2026-07-17  8:00 ` [PATCH 01/12] crypto: allwinner - Remove redundant dev_err() Pan Chuang
2026-07-17  8:13   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox