diff mbox

[v2,20/26] media: imx274: don't randomly return if range_count is zero

Message ID 13dbb41e9cd36e5d974e144c7c34bd6b0079537c.1509569763.git.mchehab@s-opensource.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mauro Carvalho Chehab Nov. 1, 2017, 9:05 p.m. UTC
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 <mchehab@s-opensource.com>
---
 drivers/media/i2c/imx274.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox

Patch

diff --git a/drivers/media/i2c/imx274.c b/drivers/media/i2c/imx274.c
index ab6a5f31da74..0d8314bfd3cb 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;