From: Colin Ian King <colin.king@xxxxxxxxxxxxx> Currently there are corner cases where spec_times is NULL and chip->parameters.onfi or when best_mode is zero where ret is not assigned a value and an uninitialized return value can be returned. Fix this by ensuring ret is initialized to -EINVAL. Addresses-Coverity: ("Uninitialized scalar variable") Fixes: 9d3194bf2aef ("mtd: rawnand: Allow SDR timings to be nacked") Fixes: a9ecc8c814e9 ("mtd: rawnand: Choose the best timings, NV-DDR included") Signed-off-by: Colin Ian King <colin.king@xxxxxxxxxxxxx> --- drivers/mtd/nand/raw/nand_base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 57a583149cc0..18db742f650c 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -926,7 +926,7 @@ int nand_choose_best_sdr_timings(struct nand_chip *chip, struct nand_sdr_timings *spec_timings) { const struct nand_controller_ops *ops = chip->controller->ops; - int best_mode = 0, mode, ret; + int best_mode = 0, mode, ret = -EINVAL; iface->type = NAND_SDR_IFACE; @@ -977,7 +977,7 @@ int nand_choose_best_nvddr_timings(struct nand_chip *chip, struct nand_nvddr_timings *spec_timings) { const struct nand_controller_ops *ops = chip->controller->ops; - int best_mode = 0, mode, ret; + int best_mode = 0, mode, ret = 0; iface->type = NAND_NVDDR_IFACE; -- 2.31.1