All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][next] mtd: rawnand: ensure return variable is initialized
@ 2021-05-27 14:50 ` Colin King
  0 siblings, 0 replies; 14+ messages in thread
From: Colin King @ 2021-05-27 14:50 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, linux-mtd
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

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@canonical.com>
---
 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


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-06-08  6:11 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-27 14:50 [PATCH][next] mtd: rawnand: ensure return variable is initialized Colin King
2021-05-27 14:50 ` Colin King
2021-05-27 15:03 ` Miquel Raynal
2021-05-27 15:03   ` Miquel Raynal
2021-05-27 15:22   ` Colin Ian King
2021-05-27 15:22     ` Colin Ian King
2021-06-01 12:14   ` Dan Carpenter
2021-06-01 12:14     ` Dan Carpenter
2021-06-01 12:58     ` Dan Carpenter
2021-06-01 12:58       ` Dan Carpenter
2021-06-07  6:57     ` Miquel Raynal
2021-06-07  6:57       ` Miquel Raynal
2021-06-08  6:10       ` Dan Carpenter
2021-06-08  6:10         ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.