summaryrefslogtreecommitdiff
path: root/drivers/media/i2c/ov9650.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/i2c/ov9650.c')
-rw-r--r--drivers/media/i2c/ov9650.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c
index 502c72238a4a..db962e2108ad 100644
--- a/drivers/media/i2c/ov9650.c
+++ b/drivers/media/i2c/ov9650.c
@@ -708,6 +708,11 @@ static int ov965x_set_gain(struct ov965x *ov965x, int auto_gain)
for (m = 6; m >= 0; m--)
if (gain >= (1 << m) * 16)
break;
+
+ /* Sanity check: don't adjust the gain with a negative value */
+ if (m < 0)
+ return -EINVAL;
+
rgain = (gain - ((1 << m) * 16)) / (1 << m);
rgain |= (((1 << m) - 1) << 4);