Commit a0d9d9b5 authored by Mikhail Arkhipov's avatar Mikhail Arkhipov Committed by Greg Kroah-Hartman
Browse files

mtd: nand: ecc-mxic: Fix use of uninitialized variable ret



[ Upstream commit d9584635 ]

If ctx->steps is zero, the loop processing ECC steps is skipped,
and the variable ret remains uninitialized. It is later checked
and returned, which leads to undefined behavior and may cause
unpredictable results in user space or kernel crashes.

This scenario can be triggered in edge cases such as misconfigured
geometry, ECC engine misuse, or if ctx->steps is not validated
after initialization.

Initialize ret to zero before the loop to ensure correct and safe
behavior regardless of the ctx->steps value.

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

Fixes: 48e6633a ("mtd: nand: mxic-ecc: Add Macronix external ECC engine support")
Signed-off-by: default avatarMikhail Arkhipov <m.arhipov@rosa.ru>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent fde31444
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment