From 00b4bac78f6f607c5882bfdc03008b7acf802349 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 1 Nov 2017 17:05:57 -0400 Subject: media: imx274: don't randomly return if range_count is zero As smatch reported: drivers/media/i2c/imx274.c:659 imx274_regmap_util_write_table_8() error: uninitialized symbol 'err'. There is a bug at imx274_regmap_util_write_table_8() with causes it to randomly return a random error if range_count is zero. Worse than that, the logic there starts with range_count equal to zero, and periodically resets it to zero again. As it is a way more likely that err assumes a non-zero value, I suspect that the chance of this code to run is very small, so, it would be worth to review the entire function. Anyway, clearly it shouldn't be returning error if range_count is zero. So, let's fix it. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/imx274.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/media/i2c/imx274.c') diff --git a/drivers/media/i2c/imx274.c b/drivers/media/i2c/imx274.c index 2f71af2f90bf..59d077b97910 100644 --- a/drivers/media/i2c/imx274.c +++ b/drivers/media/i2c/imx274.c @@ -655,6 +655,8 @@ static int imx274_regmap_util_write_table_8(struct regmap *regmap, err = regmap_bulk_write(regmap, range_start, &range_vals[0], range_count); + else + err = 0; if (err) return err; -- cgit From 021741ad36b88cb2c662dd194b80b4439ab8697e Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 5 Dec 2017 09:37:39 -0500 Subject: media: imx274: Silence uninitialized variable warning Smatch complains that "err" can be uninitialized if we have a zero size write. The flow analysis is a little complicated so I'm not sure if that's possible or not, but it's harmless to set this to zero and it makes the code easier to read. Signed-off-by: Dan Carpenter Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/imx274.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/media/i2c/imx274.c') diff --git a/drivers/media/i2c/imx274.c b/drivers/media/i2c/imx274.c index 59d077b97910..664e8acdf2a0 100644 --- a/drivers/media/i2c/imx274.c +++ b/drivers/media/i2c/imx274.c @@ -634,7 +634,7 @@ static int imx274_regmap_util_write_table_8(struct regmap *regmap, const struct reg_8 table[], u16 wait_ms_addr, u16 end_addr) { - int err; + int err = 0; const struct reg_8 *next; u8 val; -- cgit