Commit 6eb5d9ca authored by Jean Delvare's avatar Jean Delvare Committed by Mauro Carvalho Chehab

V4L/DVB (3568b): saa7111: Prevent array overrun

Explicitely state the number of registers the SAA7111 has, and use that
defined value where relevant.  This should prevent any future array overrun
like the one I just fixed in the saa7110 driver.

This patch also saves 8 bytes of memory as a side effect, as the register
cache was larger than needed.
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 62543123
...@@ -70,8 +70,10 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); ...@@ -70,8 +70,10 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
#define SAA7111_NR_REG 0x18
struct saa7111 { struct saa7111 {
unsigned char reg[32]; unsigned char reg[SAA7111_NR_REG];
int norm; int norm;
int input; int input;
...@@ -227,11 +229,11 @@ saa7111_command (struct i2c_client *client, ...@@ -227,11 +229,11 @@ saa7111_command (struct i2c_client *client,
{ {
int i; int i;
for (i = 0; i < 32; i += 16) { for (i = 0; i < SAA7111_NR_REG; i += 16) {
int j; int j;
printk(KERN_DEBUG "%s: %03x", I2C_NAME(client), i); printk(KERN_DEBUG "%s: %03x", I2C_NAME(client), i);
for (j = 0; j < 16; ++j) { for (j = 0; j < 16 && i + j < SAA7111_NR_REG; ++j) {
printk(" %02x", printk(" %02x",
saa7111_read(client, i + j)); saa7111_read(client, i + j));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment