aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorThomas Meyer <thomas@m3y3r.de>2012-01-12 14:32:04 -0500
committerJean Delvare <khali@endymion.delvare>2012-01-12 14:32:04 -0500
commita699ed6f1f977dcc4a49452a247cf21dc9cec3f9 (patch)
tree2c42055bfc32a26af0beab5b7234583a2a763448 /drivers/i2c
parent3527bd5045aacb4e4072f9cacb8eb9a433fbad39 (diff)
i2c-dev: Use memdup_user
Use memdup_user rather than duplicating its implementation. This is a little bit restricted to reduce false positives. The semantic patch that makes this output is available in scripts/coccinelle/api/memdup_user.cocci. More information about semantic patching is available at http://coccinelle.lip6.fr/ Signed-off-by: Thomas Meyer <thomas@m3y3r.de> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/i2c-dev.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 57a45ce84b2d..10e7f1e76586 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -251,15 +251,10 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
251 if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS) 251 if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS)
252 return -EINVAL; 252 return -EINVAL;
253 253
254 rdwr_pa = kmalloc(rdwr_arg.nmsgs * sizeof(struct i2c_msg), GFP_KERNEL); 254 rdwr_pa = memdup_user(rdwr_arg.msgs,
255 if (!rdwr_pa) 255 rdwr_arg.nmsgs * sizeof(struct i2c_msg));
256 return -ENOMEM; 256 if (IS_ERR(rdwr_pa))
257 257 return PTR_ERR(rdwr_pa);
258 if (copy_from_user(rdwr_pa, rdwr_arg.msgs,
259 rdwr_arg.nmsgs * sizeof(struct i2c_msg))) {
260 kfree(rdwr_pa);
261 return -EFAULT;
262 }
263 258
264 data_ptrs = kmalloc(rdwr_arg.nmsgs * sizeof(u8 __user *), GFP_KERNEL); 259 data_ptrs = kmalloc(rdwr_arg.nmsgs * sizeof(u8 __user *), GFP_KERNEL);
265 if (data_ptrs == NULL) { 260 if (data_ptrs == NULL) {