summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2014-12-13 08:52:56 -0300
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2014-12-23 10:42:51 -0200
commit50fd5e8c1e02ac471a0a4f3aaa87684a5152a0b4 (patch)
treee6fc93587a6e5ebdaadc3b8c9915f6512ddbdb96
parent7c424dd14fcf4c2905778ecd3f1ad10c5a097b5b (diff)
downloadop-kernel-dev-50fd5e8c1e02ac471a0a4f3aaa87684a5152a0b4.zip
op-kernel-dev-50fd5e8c1e02ac471a0a4f3aaa87684a5152a0b4.tar.gz
[media] hd29l2: fix sparse error and warnings
drivers/media/dvb-frontends/hd29l2.c:29:18: warning: Variable length array is used. drivers/media/dvb-frontends/hd29l2.c:34:32: error: cannot size expression drivers/media/dvb-frontends/hd29l2.c:125:5: warning: symbol 'hd29l2_rd_reg_mask' was not declared. Should it be static? Variable length arrays are frowned upon, so replace with a fixed length and check that there won't be a buffer overrun. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Reviewed-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r--drivers/media/dvb-frontends/hd29l2.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/media/dvb-frontends/hd29l2.c b/drivers/media/dvb-frontends/hd29l2.c
index d7b9d54..67c8e6d 100644
--- a/drivers/media/dvb-frontends/hd29l2.c
+++ b/drivers/media/dvb-frontends/hd29l2.c
@@ -22,20 +22,24 @@
#include "hd29l2_priv.h"
+#define HD29L2_MAX_LEN (3)
+
/* write multiple registers */
static int hd29l2_wr_regs(struct hd29l2_priv *priv, u8 reg, u8 *val, int len)
{
int ret;
- u8 buf[2 + len];
+ u8 buf[2 + HD29L2_MAX_LEN];
struct i2c_msg msg[1] = {
{
.addr = priv->cfg.i2c_addr,
.flags = 0,
- .len = sizeof(buf),
+ .len = 2 + len,
.buf = buf,
}
};
+ if (len > HD29L2_MAX_LEN)
+ return -EINVAL;
buf[0] = 0x00;
buf[1] = reg;
memcpy(&buf[2], val, len);
@@ -118,7 +122,7 @@ static int hd29l2_wr_reg_mask(struct hd29l2_priv *priv, u8 reg, u8 val, u8 mask)
}
/* read single register with mask */
-int hd29l2_rd_reg_mask(struct hd29l2_priv *priv, u8 reg, u8 *val, u8 mask)
+static int hd29l2_rd_reg_mask(struct hd29l2_priv *priv, u8 reg, u8 *val, u8 mask)
{
int ret, i;
u8 tmp;
OpenPOWER on IntegriCloud