[PATCH v14 27/30] crypto: amlogic: fix probe and algorithm registration error paths

Jose Nieto jnieto.alaber at gmail.com
Fri Nov 27 04:01:00 PST 2026


Fix error-path issues found during review:

  - meson_allocate_chanlist(): propagate a negative platform_irq_count()
    (e.g. -EPROBE_DEFER) instead of replacing it with -ENODEV, and unwind
    the
    channels already allocated when getting or requesting an IRQ fails.
  - meson_register_algs(): clear algs[i].mc before calling
    meson_unregister_algs(), so the entry that just failed to register is
    not
    unregistered again.

Signed-off-by: Jose Nieto <jnieto.alaber at gmail.com>
---
 drivers/crypto/amlogic/amlogic-gxl-core.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/amlogic/amlogic-gxl-core.c b/drivers/crypto/amlogic/amlogic-gxl-core.c
index 8ce3f6640753..c11d7d8250ea 100644
--- a/drivers/crypto/amlogic/amlogic-gxl-core.c
+++ b/drivers/crypto/amlogic/amlogic-gxl-core.c
@@ -106,7 +106,9 @@ static int meson_allocate_chanlist(struct meson_dev *mc)
 	int i, err;
 
 	mc->flow_cnt = platform_irq_count(pdev);
-	if (mc->flow_cnt <= 0) {
+	if (mc->flow_cnt < 0)
+		return mc->flow_cnt;
+	if (mc->flow_cnt == 0) {
 		dev_err(mc->dev, "No IRQs defined\n");
 		return -ENODEV;
 	}
@@ -117,14 +119,18 @@ static int meson_allocate_chanlist(struct meson_dev *mc)
 
 	for (i = 0; i < mc->flow_cnt; i++) {
 		mc->chanlist[i].irq = platform_get_irq(pdev, i);
-		if (mc->chanlist[i].irq < 0)
-			return mc->chanlist[i].irq;
+		if (mc->chanlist[i].irq < 0) {
+			err = mc->chanlist[i].irq;
+			i--;
+			goto error_engine;
+		}
 
 		err = devm_request_irq(mc->dev, mc->chanlist[i].irq,
 				       meson_irq_handler, 0, "aml-crypto", mc);
 		if (err < 0) {
 			dev_err(mc->dev, "Cannot request IRQ for flow %d\n", i);
-			return err;
+			i--;
+			goto error_engine;
 		}
 
 		init_completion(&mc->chanlist[i].complete);
@@ -169,6 +175,7 @@ int meson_register_algs(struct meson_dev *mc, struct meson_alg_template *algs,
 			if (err) {
 				dev_err(mc->dev, "Fail to register %s\n",
 					algs[i].alg.skcipher.base.base.cra_name);
+				algs[i].mc = NULL;
 				meson_unregister_algs(mc, algs, count);
 				return err;
 			}
@@ -178,6 +185,7 @@ int meson_register_algs(struct meson_dev *mc, struct meson_alg_template *algs,
 			if (err) {
 				dev_err(mc->dev, "Fail to register %s\n",
 					algs[i].alg.ahash.base.halg.base.cra_name);
+				algs[i].mc = NULL;
 				meson_unregister_algs(mc, algs, count);
 				return err;
 			}
-- 
2.47.3




More information about the linux-arm-kernel mailing list