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: Jean Delvare <[EMAIL PROTECTED]>
---
 drivers/media/video/saa7111.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

--- linux-2.6.15-rc6.orig/drivers/media/video/saa7111.c 2005-12-23 
11:07:14.000000000 +0100
+++ linux-2.6.15-rc6/drivers/media/video/saa7111.c      2005-12-26 
10:40:26.000000000 +0100
@@ -70,8 +70,10 @@
 
 /* ----------------------------------------------------------------------- */
 
+#define SAA7111_NR_REG         0x18
+
 struct saa7111 {
-       unsigned char reg[32];
+       unsigned char reg[SAA7111_NR_REG];
 
        int norm;
        int input;
@@ -227,11 +229,11 @@
        {
                int i;
 
-               for (i = 0; i < 32; i += 16) {
+               for (i = 0; i < SAA7111_NR_REG; i += 16) {
                        int j;
 
                        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",
                                       saa7111_read(client, i + j));
                        }

-- 
Jean Delvare


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Mjpeg-users mailing list
Mjpeg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mjpeg-users

Reply via email to