Skip to contentSkip to conversation

from kernel 2.4 i2c-dev and i2c-core for CVS

PATCH New Albert Cranford 1 participant 1 message May 19, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 from kernel 2.4 i2c-dev and i2c-core for CVS

Hi all,
Below are two patches that showed up in the 2.4 kernel from Alan Cox. i2c-dev limits the amount of data copied from/to user_space from/to kernel_space in i2cdev_read and i2cdev_write.
i2c-core.c changes len_total from and int to size_t. I've tested on 2.2, 2.4 and 2.5 kernels. If no one objects I'll update CVS to reflect Alan's changes.
Albert

i2c-dev.c 2002-09-29 12:29:48.000000000 -0400 renamed from i2c-dev.c.orig 2002-09-29 12:26:18.000000000 -0400 +6 -0
@@ -145,6 +145,9 @@
 
        struct i2c_client *client = (struct i2c_client *)file->private_data;
 
+       if (count > 8192)
+               count = 8192;
+
        /* copy user space data to kernel space. */
        tmp = kmalloc(count,GFP_KERNEL);
        if (tmp=NULL)
@@ -173,6 +176,9 @@
        struct inode *inode = file->f_dentry->d_inode;
 #endif /* DEBUG */
 
+       if (count > 8192)
+               count = 8192;
+
        /* copy user space data to kernel space. */
        tmp = kmalloc(count,GFP_KERNEL);
        if (tmp=NULL)

---------------

i2c-core.c 2002-09-29 12:46:10.000000000 -0400 renamed from i2c-core.c.orig 2002-09-29 12:32:45.000000000 -0400 +2 -1
@@ -654,7 +654,8 @@
        struct inode * inode = file->f_dentry->d_inode;
        char *kbuf;
        struct i2c_client *client;
-       int i,j,k,order_nr,len=0,len_total;
+       int i,j,k,order_nr,len=0;
+       size_t len_total;
        int order[I2C_CLIENT_MAX];
 #define OUTPUT_LENGTH_PER_LINE 70
 
Signature · 2 lines
Albert Cranford Deerfield Beach FL USA
[email protected]