[PATCH] mtd: spinand: cleanup ECC engine when spinand_randomizer_init() fails

From: Gabor Juhos

Date: Thu Nov 19 2026 - 03:15:07 EST


When the spinand_randomizer_init() fails, the code jumps to the
'err_cleanup_nanddev' label and the code leaves the ECC engine
initialized.

Change the respective goto statement to use the correct label which
ensures that the ECC engine gets cleaned up correctly.

Cc: stable@xxxxxxxxxxxxxxx
Fixes: 54e1bc80af0c ("mtd: spinand: Add support for randomizer")
Signed-off-by: Gabor Juhos <j4g8y7@xxxxxxxxx>
---
drivers/mtd/nand/spi/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index 18bba02fbd31..f6741d121b70 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -1982,7 +1982,7 @@ static int spinand_init(struct spinand_device *spinand)
spinand_cont_read_init(spinand);
ret = spinand_randomizer_init(spinand);
if (ret)
- goto err_cleanup_nanddev;
+ goto err_cleanup_ecc_engine;

mtd->_read_oob = spinand_mtd_read;
mtd->_write_oob = spinand_mtd_write;

---
base-commit: 760d2efe91a84363d25c1051a10572242e75fe86
change-id: 20261118-spinand-cleanup-ecc-engine-da1af0ceae46

Best regards,
--
Gabor Juhos <j4g8y7@xxxxxxxxx>