[PATCH] mtd: spinand: initialize ret in regular page reads

From: Ruoyu Wang

Date: Wed Jun 17 2026 - 14:46:14 EST


spinand_mtd_regular_page_read() returns ret after iterating over the
requested pages. If the request contains no data or OOB bytes, the
iterator does not run and ret is not assigned. Initialize it to 0 for the
empty request path.

Signed-off-by: Ruoyu Wang <ruoyuw560@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 786e3fb4874d8..051af3e1cf5ea 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -817,7 +817,7 @@ static int spinand_mtd_regular_page_read(struct mtd_info *mtd, loff_t from,
bool disable_ecc = false;
bool ecc_failed = false;
unsigned int retry_mode = 0;
- int ret;
+ int ret = 0;

old_stats = mtd->ecc_stats;

--
2.51.0