]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] Overflow checks in i2c
authorDave Jones <davej@codemonkey.org.uk>
Mon, 25 Nov 2002 10:32:02 +0000 (02:32 -0800)
committerDave Jones <davej@codemonkey.org.uk>
Mon, 25 Nov 2002 10:32:02 +0000 (02:32 -0800)
drivers/i2c/i2c-dev.c

index 461f823316918319f5227ad0cacc50dd319e6a1b..5b64c887a9e51637a765c9df380542f7e530c393 100644 (file)
@@ -115,6 +115,9 @@ static ssize_t i2cdev_read (struct file *file, char *buf, size_t count,
 
        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)
@@ -143,6 +146,9 @@ static ssize_t i2cdev_write (struct file *file, const char *buf, size_t count,
        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)