Commit 0d8bc4d7 authored by Dave Jones's avatar Dave Jones

[PATCH] Overflow checks in i2c

parent b362ea98
...@@ -115,6 +115,9 @@ static ssize_t i2cdev_read (struct file *file, char *buf, size_t count, ...@@ -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; struct i2c_client *client = (struct i2c_client *)file->private_data;
if(count > 8192)
count = 8192;
/* copy user space data to kernel space. */ /* copy user space data to kernel space. */
tmp = kmalloc(count,GFP_KERNEL); tmp = kmalloc(count,GFP_KERNEL);
if (tmp==NULL) if (tmp==NULL)
...@@ -143,6 +146,9 @@ static ssize_t i2cdev_write (struct file *file, const char *buf, size_t count, ...@@ -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; struct inode *inode = file->f_dentry->d_inode;
#endif /* DEBUG */ #endif /* DEBUG */
if(count > 8192)
count = 8192;
/* copy user space data to kernel space. */ /* copy user space data to kernel space. */
tmp = kmalloc(count,GFP_KERNEL); tmp = kmalloc(count,GFP_KERNEL);
if (tmp==NULL) if (tmp==NULL)
......
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