summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWenjia Zhou <wenjiaz@nvidia.com>2017-02-17 21:00:40 -0500
committerBhanu Murthy V <bmurthyv@nvidia.com>2017-03-22 13:38:29 -0400
commit6cb1e4413847fb0ee64bd815d9cde7aae1d61cf1 (patch)
tree896d12fe0aeb1773bc8e36a8fa051c335ab6a0bc
parent3f1a4170d75511d8e92c988d27f5e955fb75ff2c (diff)
media:i2c: fix coverity defects
Fixed out of bound access Fixed wrong shift value to compute gain Coverity ID 29587 Coverity ID 36185 Bug 200192387 Change-Id: I60999628c38192c41ce7e75099b65643d7476f2c Signed-off-by: Wenjia Zhou <wenjiaz@nvidia.com> Reviewed-on: http://git-master/r/1307363 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Shubham Chandra <shubhamc@nvidia.com> Reviewed-by: Frank Chen <frankc@nvidia.com> Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Bhanu Murthy V <bmurthyv@nvidia.com>
-rw-r--r--drivers/media/i2c/lc898212.c9
-rw-r--r--drivers/media/i2c/ov23850.c4
2 files changed, 6 insertions, 7 deletions
diff --git a/drivers/media/i2c/lc898212.c b/drivers/media/i2c/lc898212.c
index 621b97f3f..44cdb876e 100644
--- a/drivers/media/i2c/lc898212.c
+++ b/drivers/media/i2c/lc898212.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved. 2 * Copyright (c) 2015-2017, NVIDIA CORPORATION. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License, 5 * under the terms and conditions of the GNU General Public License,
@@ -327,14 +327,13 @@ static unsigned int convert_signed16b_to_unsigned10b(s16 data)
327static int lc898212_init(struct lc898212 *priv) 327static int lc898212_init(struct lc898212 *priv)
328{ 328{
329 int err; 329 int err;
330 u16 data; 330 int data;
331 331
332 err = lc898212_write_table(priv, lc898212_init_setting); 332 err = lc898212_write_table(priv, lc898212_init_setting);
333 333
334 err |= regmap_read(priv->regmap16, LC898212_ADOFFSET, 334 err |= regmap_read(priv->regmap16, LC898212_ADOFFSET, &data);
335 (unsigned int *) &data);
336 priv->s_data->def_position = 335 priv->s_data->def_position =
337 convert_signed16b_to_unsigned10b((s16)data); 336 convert_signed16b_to_unsigned10b((s16)(data & 0xffff));
338 err |= regmap_write(priv->regmap16, LC898212_RZ, data); 337 err |= regmap_write(priv->regmap16, LC898212_RZ, data);
339 338
340 /* Servo On */ 339 /* Servo On */
diff --git a/drivers/media/i2c/ov23850.c b/drivers/media/i2c/ov23850.c
index 141287d8e..bad408019 100644
--- a/drivers/media/i2c/ov23850.c
+++ b/drivers/media/i2c/ov23850.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * ov23850.c - ov23850 sensor driver 2 * ov23850.c - ov23850 sensor driver
3 * 3 *
4 * Copyright (c) 2013-2016, NVIDIA CORPORATION. All rights reserved. 4 * Copyright (c) 2013-2017, NVIDIA CORPORATION. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License, 7 * under the terms and conditions of the GNU General Public License,
@@ -252,7 +252,7 @@ static inline void ov23850_get_gain_reg(ov23850_reg *regs,
252 u16 gain) 252 u16 gain)
253{ 253{
254 regs->addr = OV23850_GAIN_ADDR_MSB; 254 regs->addr = OV23850_GAIN_ADDR_MSB;
255 regs->val = (gain >> 16) & 0x07; 255 regs->val = (gain >> 8) & 0x07;
256 (regs + 1)->addr = OV23850_GAIN_ADDR_LSB; 256 (regs + 1)->addr = OV23850_GAIN_ADDR_LSB;
257 (regs + 1)->val = (gain) & 0xff; 257 (regs + 1)->val = (gain) & 0xff;
258} 258}