public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/13] go7007: don't use vb before test if it is not NULL
@ 2015-04-28 23:04 Mauro Carvalho Chehab
  2015-04-28 23:04 ` [PATCH 02/13] benq: fix indentation Mauro Carvalho Chehab
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Mauro Carvalho Chehab @ 2015-04-28 23:04 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Hans Verkuil

As reported by smatch:
	drivers/media/usb/go7007/go7007-driver.c:452 frame_boundary() warn: variable dereferenced before check 'vb' (see line 449)

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/usb/go7007/go7007-driver.c b/drivers/media/usb/go7007/go7007-driver.c
index 95cffb771a62..0ab81ec8897a 100644
--- a/drivers/media/usb/go7007/go7007-driver.c
+++ b/drivers/media/usb/go7007/go7007-driver.c
@@ -446,7 +446,7 @@ static void go7007_motion_regions(struct go7007 *go, struct go7007_buffer *vb)
  */
 static struct go7007_buffer *frame_boundary(struct go7007 *go, struct go7007_buffer *vb)
 {
-	u32 *bytesused = &vb->vb.v4l2_planes[0].bytesused;
+	u32 *bytesused;
 	struct go7007_buffer *vb_tmp = NULL;
 
 	if (vb == NULL) {
@@ -458,6 +458,7 @@ static struct go7007_buffer *frame_boundary(struct go7007 *go, struct go7007_buf
 		go->next_seq++;
 		return vb;
 	}
+	bytesused = &vb->vb.v4l2_planes[0].bytesused;
 
 	vb->vb.v4l2_buf.sequence = go->next_seq++;
 	if (vb->modet_active && *bytesused + 216 < GO7007_BUF_SIZE)
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 02/13] benq: fix indentation
  2015-04-28 23:04 [PATCH 01/13] go7007: don't use vb before test if it is not NULL Mauro Carvalho Chehab
@ 2015-04-28 23:04 ` Mauro Carvalho Chehab
  2015-04-28 23:04 ` [PATCH 03/13] bcm3510: " Mauro Carvalho Chehab
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Mauro Carvalho Chehab @ 2015-04-28 23:04 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Hans de Goede

drivers/media/usb/gspca/benq.c:239 sd_isoc_irq() warn: inconsistent indenting

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/usb/gspca/benq.c b/drivers/media/usb/gspca/benq.c
index 05f406deae13..790baed33963 100644
--- a/drivers/media/usb/gspca/benq.c
+++ b/drivers/media/usb/gspca/benq.c
@@ -236,8 +236,8 @@ static void sd_isoc_irq(struct urb *urb)
 		}
 		data = (u8 *) urb->transfer_buffer
 					+ urb->iso_frame_desc[i].offset;
-			gspca_frame_add(gspca_dev, INTER_PACKET,
-					data, SD_PKT_SZ);
+		gspca_frame_add(gspca_dev, INTER_PACKET,
+				data, SD_PKT_SZ);
 	}
 
 	/* resubmit the URBs */
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 03/13] bcm3510: fix indentation
  2015-04-28 23:04 [PATCH 01/13] go7007: don't use vb before test if it is not NULL Mauro Carvalho Chehab
  2015-04-28 23:04 ` [PATCH 02/13] benq: fix indentation Mauro Carvalho Chehab
@ 2015-04-28 23:04 ` Mauro Carvalho Chehab
  2015-04-28 23:04 ` [PATCH 04/13] dib3000mc: Fix indentation Mauro Carvalho Chehab
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Mauro Carvalho Chehab @ 2015-04-28 23:04 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Hans Verkuil

drivers/media/dvb-frontends/bcm3510.c:688 bcm3510_reset() warn: inconsistent indenting
drivers/media/dvb-frontends/bcm3510.c:711 bcm3510_clear_reset() warn: inconsistent indenting

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/dvb-frontends/bcm3510.c b/drivers/media/dvb-frontends/bcm3510.c
index 638c7aa0fb7e..23bfd00d42db 100644
--- a/drivers/media/dvb-frontends/bcm3510.c
+++ b/drivers/media/dvb-frontends/bcm3510.c
@@ -685,7 +685,7 @@ static int bcm3510_reset(struct bcm3510_state *st)
 	if ((ret = bcm3510_writeB(st,0xa0,v)) < 0)
 		return ret;
 
-    t = jiffies + 3*HZ;
+	t = jiffies + 3*HZ;
 	while (time_before(jiffies, t)) {
 		msleep(10);
 		if ((ret = bcm3510_readB(st,0xa2,&v)) < 0)
@@ -708,7 +708,7 @@ static int bcm3510_clear_reset(struct bcm3510_state *st)
 	if ((ret = bcm3510_writeB(st,0xa0,v)) < 0)
 		return ret;
 
-    t = jiffies + 3*HZ;
+	t = jiffies + 3*HZ;
 	while (time_before(jiffies, t)) {
 		msleep(10);
 		if ((ret = bcm3510_readB(st,0xa2,&v)) < 0)
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 04/13] dib3000mc: Fix indentation
  2015-04-28 23:04 [PATCH 01/13] go7007: don't use vb before test if it is not NULL Mauro Carvalho Chehab
  2015-04-28 23:04 ` [PATCH 02/13] benq: fix indentation Mauro Carvalho Chehab
  2015-04-28 23:04 ` [PATCH 03/13] bcm3510: " Mauro Carvalho Chehab
@ 2015-04-28 23:04 ` Mauro Carvalho Chehab
  2015-04-28 23:04 ` [PATCH 05/13] lgdt3306a: fix indentation Mauro Carvalho Chehab
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Mauro Carvalho Chehab @ 2015-04-28 23:04 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab

drivers/media/dvb-frontends/dib3000mc.c:134 dib3000mc_setup_pwm_state() warn: inconsistent indenting
drivers/media/dvb-frontends/dib3000mc.c:144 dib3000mc_setup_pwm_state() warn: inconsistent indenting
drivers/media/dvb-frontends/dib3000mc.c:420 dib3000mc_sleep() warn: inconsistent indenting
drivers/media/dvb-frontends/dib3000mc.c:453 dib3000mc_set_channel_cfg() warn: inconsistent indenting

The last one is actually due to a commented code. Let's rework
it, in order to remove the sparse warning without removing the
dead code, as it may be useful in the future.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/dvb-frontends/dib3000mc.c b/drivers/media/dvb-frontends/dib3000mc.c
index ffad181a9692..ba5e832eb1d4 100644
--- a/drivers/media/dvb-frontends/dib3000mc.c
+++ b/drivers/media/dvb-frontends/dib3000mc.c
@@ -131,7 +131,7 @@ static int dib3000mc_set_timing(struct dib3000mc_state *state, s16 nfft, u32 bw,
 static int dib3000mc_setup_pwm_state(struct dib3000mc_state *state)
 {
 	u16 reg_51, reg_52 = state->cfg->agc->setup & 0xfefb;
-    if (state->cfg->pwm3_inversion) {
+	if (state->cfg->pwm3_inversion) {
 		reg_51 =  (2 << 14) | (0 << 10) | (7 << 6) | (2 << 2) | (2 << 0);
 		reg_52 |= (1 << 2);
 	} else {
@@ -141,7 +141,7 @@ static int dib3000mc_setup_pwm_state(struct dib3000mc_state *state)
 	dib3000mc_write_word(state, 51, reg_51);
 	dib3000mc_write_word(state, 52, reg_52);
 
-    if (state->cfg->use_pwm3)
+	if (state->cfg->use_pwm3)
 		dib3000mc_write_word(state, 245, (1 << 3) | (1 << 0));
 	else
 		dib3000mc_write_word(state, 245, 0);
@@ -417,7 +417,7 @@ static int dib3000mc_sleep(struct dvb_frontend *demod)
 	dib3000mc_write_word(state, 1032, 0xFFFF);
 	dib3000mc_write_word(state, 1033, 0xFFF0);
 
-    return 0;
+	return 0;
 }
 
 static void dib3000mc_set_adp_cfg(struct dib3000mc_state *state, s16 qam)
@@ -447,10 +447,14 @@ static void dib3000mc_set_channel_cfg(struct dib3000mc_state *state,
 	dib3000mc_set_bandwidth(state, bw);
 	dib3000mc_set_timing(state, ch->transmission_mode, bw, 0);
 
-//	if (boost)
-//		dib3000mc_write_word(state, 100, (11 << 6) + 6);
-//	else
+#if 1
+	dib3000mc_write_word(state, 100, (16 << 6) + 9);
+#else
+	if (boost)
+		dib3000mc_write_word(state, 100, (11 << 6) + 6);
+	else
 		dib3000mc_write_word(state, 100, (16 << 6) + 9);
+#endif
 
 	dib3000mc_write_word(state, 1027, 0x0800);
 	dib3000mc_write_word(state, 1027, 0x0000);
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 05/13] lgdt3306a: fix indentation
  2015-04-28 23:04 [PATCH 01/13] go7007: don't use vb before test if it is not NULL Mauro Carvalho Chehab
                   ` (2 preceding siblings ...)
  2015-04-28 23:04 ` [PATCH 04/13] dib3000mc: Fix indentation Mauro Carvalho Chehab
@ 2015-04-28 23:04 ` Mauro Carvalho Chehab
  2015-04-28 23:04 ` [PATCH 06/13] stv0288: " Mauro Carvalho Chehab
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Mauro Carvalho Chehab @ 2015-04-28 23:04 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Michael Ira Krufky,
	Fred Richter

drivers/media/dvb-frontends/lgdt3306a.c:2104 lgdt3306a_DumpRegs() warn: inconsistent indenting

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/dvb-frontends/lgdt3306a.c b/drivers/media/dvb-frontends/lgdt3306a.c
index d9a2b0e768e0..0e2e43e9ede5 100644
--- a/drivers/media/dvb-frontends/lgdt3306a.c
+++ b/drivers/media/dvb-frontends/lgdt3306a.c
@@ -2101,7 +2101,7 @@ static void lgdt3306a_DumpRegs(struct lgdt3306a_state *state)
 		lgdt3306a_read_reg(state, regtab[i], &regval1[i]);
 		if (regval1[i] != regval2[i]) {
 			lg_debug(" %04X = %02X\n", regtab[i], regval1[i]);
-				 regval2[i] = regval1[i];
+			regval2[i] = regval1[i];
 		}
 	}
 	debug = sav_debug;
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 06/13] stv0288: fix indentation
  2015-04-28 23:04 [PATCH 01/13] go7007: don't use vb before test if it is not NULL Mauro Carvalho Chehab
                   ` (3 preceding siblings ...)
  2015-04-28 23:04 ` [PATCH 05/13] lgdt3306a: fix indentation Mauro Carvalho Chehab
@ 2015-04-28 23:04 ` Mauro Carvalho Chehab
  2015-04-28 23:04 ` [PATCH 07/13] s5h1420: fix a buffer overflow when checking userspace params Mauro Carvalho Chehab
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Mauro Carvalho Chehab @ 2015-04-28 23:04 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab

drivers/media/dvb-frontends/stv0288.c:137 stv0288_set_symbolrate() warn: inconsistent indenting

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/dvb-frontends/stv0288.c b/drivers/media/dvb-frontends/stv0288.c
index 632b25156e4c..ecf4bb3a3b6b 100644
--- a/drivers/media/dvb-frontends/stv0288.c
+++ b/drivers/media/dvb-frontends/stv0288.c
@@ -134,20 +134,20 @@ static int stv0288_set_symbolrate(struct dvb_frontend *fe, u32 srate)
 
 	temp = (unsigned int)srate / 1000;
 
-		temp = temp * 32768;
-		temp = temp / 25;
-		temp = temp / 125;
-		b[0] = (unsigned char)((temp >> 12) & 0xff);
-		b[1] = (unsigned char)((temp >> 4) & 0xff);
-		b[2] = (unsigned char)((temp << 4) & 0xf0);
-		stv0288_writeregI(state, 0x28, 0x80); /* SFRH */
-		stv0288_writeregI(state, 0x29, 0); /* SFRM */
-		stv0288_writeregI(state, 0x2a, 0); /* SFRL */
+	temp = temp * 32768;
+	temp = temp / 25;
+	temp = temp / 125;
+	b[0] = (unsigned char)((temp >> 12) & 0xff);
+	b[1] = (unsigned char)((temp >> 4) & 0xff);
+	b[2] = (unsigned char)((temp << 4) & 0xf0);
+	stv0288_writeregI(state, 0x28, 0x80); /* SFRH */
+	stv0288_writeregI(state, 0x29, 0); /* SFRM */
+	stv0288_writeregI(state, 0x2a, 0); /* SFRL */
 
-		stv0288_writeregI(state, 0x28, b[0]);
-		stv0288_writeregI(state, 0x29, b[1]);
-		stv0288_writeregI(state, 0x2a, b[2]);
-		dprintk("stv0288: stv0288_set_symbolrate\n");
+	stv0288_writeregI(state, 0x28, b[0]);
+	stv0288_writeregI(state, 0x29, b[1]);
+	stv0288_writeregI(state, 0x2a, b[2]);
+	dprintk("stv0288: stv0288_set_symbolrate\n");
 
 	return 0;
 }
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 07/13] s5h1420: fix a buffer overflow when checking userspace params
  2015-04-28 23:04 [PATCH 01/13] go7007: don't use vb before test if it is not NULL Mauro Carvalho Chehab
                   ` (4 preceding siblings ...)
  2015-04-28 23:04 ` [PATCH 06/13] stv0288: " Mauro Carvalho Chehab
@ 2015-04-28 23:04 ` Mauro Carvalho Chehab
  2015-04-28 23:04 ` [PATCH 08/13] cx24116: " Mauro Carvalho Chehab
  2015-04-30  6:22 ` [PATCH 01/13] go7007: don't use vb before test if it is not NULL Hans Verkuil
  7 siblings, 0 replies; 9+ messages in thread
From: Mauro Carvalho Chehab @ 2015-04-28 23:04 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, stable

The maximum size for a DiSEqC command is 6, according to the
userspace API. However, the code allows to write up to 7 values:
	drivers/media/dvb-frontends/s5h1420.c:193 s5h1420_send_master_cmd() error: buffer overflow 'cmd->msg' 6 <= 7

Cc: stable@vger.kernel.org
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/dvb-frontends/s5h1420.c b/drivers/media/dvb-frontends/s5h1420.c
index 93eeaf7118fd..0b4f8fe6bf99 100644
--- a/drivers/media/dvb-frontends/s5h1420.c
+++ b/drivers/media/dvb-frontends/s5h1420.c
@@ -180,7 +180,7 @@ static int s5h1420_send_master_cmd (struct dvb_frontend* fe,
 	int result = 0;
 
 	dprintk("enter %s\n", __func__);
-	if (cmd->msg_len > 8)
+	if (cmd->msg_len > sizeof(cmd->msg))
 		return -EINVAL;
 
 	/* setup for DISEQC */
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 08/13] cx24116: fix a buffer overflow when checking userspace params
  2015-04-28 23:04 [PATCH 01/13] go7007: don't use vb before test if it is not NULL Mauro Carvalho Chehab
                   ` (5 preceding siblings ...)
  2015-04-28 23:04 ` [PATCH 07/13] s5h1420: fix a buffer overflow when checking userspace params Mauro Carvalho Chehab
@ 2015-04-28 23:04 ` Mauro Carvalho Chehab
  2015-04-30  6:22 ` [PATCH 01/13] go7007: don't use vb before test if it is not NULL Hans Verkuil
  7 siblings, 0 replies; 9+ messages in thread
From: Mauro Carvalho Chehab @ 2015-04-28 23:04 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, stable

The maximum size for a DiSEqC command is 6, according to the
userspace API. However, the code allows to write up much more values:
	drivers/media/dvb-frontends/cx24116.c:983 cx24116_send_diseqc_msg() error: buffer overflow 'd->msg' 6 <= 23

Cc: stable@vger.kernel.org
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

diff --git a/drivers/media/dvb-frontends/cx24116.c b/drivers/media/dvb-frontends/cx24116.c
index 2916d7c74a1d..7bc68b355c0b 100644
--- a/drivers/media/dvb-frontends/cx24116.c
+++ b/drivers/media/dvb-frontends/cx24116.c
@@ -963,6 +963,10 @@ static int cx24116_send_diseqc_msg(struct dvb_frontend *fe,
 	struct cx24116_state *state = fe->demodulator_priv;
 	int i, ret;
 
+	/* Validate length */
+	if (d->msg_len > sizeof(d->msg))
+                return -EINVAL;
+
 	/* Dump DiSEqC message */
 	if (debug) {
 		printk(KERN_INFO "cx24116: %s(", __func__);
@@ -974,10 +978,6 @@ static int cx24116_send_diseqc_msg(struct dvb_frontend *fe,
 		printk(") toneburst=%d\n", toneburst);
 	}
 
-	/* Validate length */
-	if (d->msg_len > (CX24116_ARGLEN - CX24116_DISEQC_MSGOFS))
-		return -EINVAL;
-
 	/* DiSEqC message */
 	for (i = 0; i < d->msg_len; i++)
 		state->dsec_cmd.args[CX24116_DISEQC_MSGOFS + i] = d->msg[i];
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 01/13] go7007: don't use vb before test if it is not NULL
  2015-04-28 23:04 [PATCH 01/13] go7007: don't use vb before test if it is not NULL Mauro Carvalho Chehab
                   ` (6 preceding siblings ...)
  2015-04-28 23:04 ` [PATCH 08/13] cx24116: " Mauro Carvalho Chehab
@ 2015-04-30  6:22 ` Hans Verkuil
  7 siblings, 0 replies; 9+ messages in thread
From: Hans Verkuil @ 2015-04-30  6:22 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Hans Verkuil

On 04/29/2015 01:04 AM, Mauro Carvalho Chehab wrote:
> As reported by smatch:
> 	drivers/media/usb/go7007/go7007-driver.c:452 frame_boundary() warn: variable dereferenced before check 'vb' (see line 449)
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

> 
> diff --git a/drivers/media/usb/go7007/go7007-driver.c b/drivers/media/usb/go7007/go7007-driver.c
> index 95cffb771a62..0ab81ec8897a 100644
> --- a/drivers/media/usb/go7007/go7007-driver.c
> +++ b/drivers/media/usb/go7007/go7007-driver.c
> @@ -446,7 +446,7 @@ static void go7007_motion_regions(struct go7007 *go, struct go7007_buffer *vb)
>   */
>  static struct go7007_buffer *frame_boundary(struct go7007 *go, struct go7007_buffer *vb)
>  {
> -	u32 *bytesused = &vb->vb.v4l2_planes[0].bytesused;
> +	u32 *bytesused;
>  	struct go7007_buffer *vb_tmp = NULL;
>  
>  	if (vb == NULL) {
> @@ -458,6 +458,7 @@ static struct go7007_buffer *frame_boundary(struct go7007 *go, struct go7007_buf
>  		go->next_seq++;
>  		return vb;
>  	}
> +	bytesused = &vb->vb.v4l2_planes[0].bytesused;
>  
>  	vb->vb.v4l2_buf.sequence = go->next_seq++;
>  	if (vb->modet_active && *bytesused + 216 < GO7007_BUF_SIZE)
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-04-30  6:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-28 23:04 [PATCH 01/13] go7007: don't use vb before test if it is not NULL Mauro Carvalho Chehab
2015-04-28 23:04 ` [PATCH 02/13] benq: fix indentation Mauro Carvalho Chehab
2015-04-28 23:04 ` [PATCH 03/13] bcm3510: " Mauro Carvalho Chehab
2015-04-28 23:04 ` [PATCH 04/13] dib3000mc: Fix indentation Mauro Carvalho Chehab
2015-04-28 23:04 ` [PATCH 05/13] lgdt3306a: fix indentation Mauro Carvalho Chehab
2015-04-28 23:04 ` [PATCH 06/13] stv0288: " Mauro Carvalho Chehab
2015-04-28 23:04 ` [PATCH 07/13] s5h1420: fix a buffer overflow when checking userspace params Mauro Carvalho Chehab
2015-04-28 23:04 ` [PATCH 08/13] cx24116: " Mauro Carvalho Chehab
2015-04-30  6:22 ` [PATCH 01/13] go7007: don't use vb before test if it is not NULL Hans Verkuil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox