Commit 70a71f81 authored by Ivan Stepchenko's avatar Ivan Stepchenko Committed by Miquel Raynal
Browse files

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: 49dc08ee ("[MTD] [OneNAND] fix numerous races")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarIvan Stepchenko <sid@itb.spb.ru>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
parent ae461cde
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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);