Skip to contentSkip to conversation

mtd: onenand: Fix uninitialized retlen in do_otp_read()

PATCH Applied Ivan Stepchenko 2 participants 2 messages Nov 14, 2024 – Dec 5, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: onenand: Fix uninitialized retlen in do_otp_read()

The function do_otp_read() does not set the output parameter *retlen, which is expected to contain the number of bytes actually read. As a result, in onenand_otp_walk(), the tmp_retlen variable remains uninitialized after calling do_otp_walk() and used to change the values of the buf, len and retlen variables.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes 49dc08eeda70 ("[MTD] [OneNAND] fix numerous races")
---
 drivers/mtd/nand/onenand/onenand_base.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/nand/onenand/onenand_base.c +1 -0
index f66385faf631..0dc2ea4fc857 100644
@@ -2923,6 +2923,7 @@ static int do_otp_read(struct mtd_info *mtd, loff_t from, size_t len,
 	ret = ONENAND_IS_4KB_PAGE(this) ?
 		onenand_mlc_read_ops_nolock(mtd, from, &ops) :
 		onenand_read_ops_nolock(mtd, from, &ops);
+	*retlen = ops.retlen;
 
 	/* Exit OTP access mode */
 	this->command(mtd, ONENAND_CMD_RESET, 0, 0);
Signature · 1 line
2.34.1
maintainer Applied
#1 lore raw
Quoted 9 lines · Ivan Stepchenko

The function do_otp_read() does not set the output parameter *retlen, which is expected to contain the number of bytes actually read. As a result, in onenand_otp_walk(), the tmp_retlen variable remains uninitialized after calling do_otp_walk() and used to change the values of the buf, len and retlen variables.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

[...]

Applied to nand/next, thanks!

[1/1] mtd: onenand: Fix uninitialized retlen in do_otp_read()

Patche(s) will be available within hours on:
mtd/linux.git

Kind regards,
Miquèl