diff options
author | aalexandrovich <88376726+aalexandrovich@users.noreply.github.com> | 2021-08-23 16:44:22 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-23 16:44:22 +0300 |
commit | 11e4e66efd440216032f53ee7e5ca08cd263a292 (patch) | |
tree | 630237ec37435734f29cc4ea2c91a75813d61053 /drivers/i2c/i2c-dev.c | |
parent | 96b18047a7172037ff4206720f4e889670030b41 (diff) | |
parent | e22ce8eb631bdc47a4a4ea7ecf4e4ba499db4f93 (diff) |
Merge branch 'torvalds:master' into master
Diffstat (limited to 'drivers/i2c/i2c-dev.c')
-rw-r--r-- | drivers/i2c/i2c-dev.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index cb64fe649390..77f576e51652 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -141,7 +141,7 @@ static ssize_t i2cdev_read(struct file *file, char __user *buf, size_t count, if (count > 8192) count = 8192; - tmp = kmalloc(count, GFP_KERNEL); + tmp = kzalloc(count, GFP_KERNEL); if (tmp == NULL) return -ENOMEM; @@ -150,7 +150,8 @@ static ssize_t i2cdev_read(struct file *file, char __user *buf, size_t count, ret = i2c_master_recv(client, tmp, count); if (ret >= 0) - ret = copy_to_user(buf, tmp, count) ? -EFAULT : ret; + if (copy_to_user(buf, tmp, ret)) + ret = -EFAULT; kfree(tmp); return ret; } |