Merge branch 'uaccess.__copy_to_user' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull uaccess/__copy_to_user updates from Al Viro: "Getting rid of __copy_to_user() callers - stuff that doesn't fit into other series" * 'uaccess.__copy_to_user' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: dlmfs: convert dlmfs_file_read() to copy_to_user() esas2r: don't bother with __copy_to_user()
This commit is contained in:
@@ -1510,7 +1510,7 @@ ioctl_done:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Always copy the buffer back, if only to pick up the status */
|
/* Always copy the buffer back, if only to pick up the status */
|
||||||
err = __copy_to_user(arg, ioctl, sizeof(struct atto_express_ioctl));
|
err = copy_to_user(arg, ioctl, sizeof(struct atto_express_ioctl));
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
esas2r_log(ESAS2R_LOG_WARN,
|
esas2r_log(ESAS2R_LOG_WARN,
|
||||||
"ioctl_handler copy_to_user didn't copy everything (err %d, cmd %u)",
|
"ioctl_handler copy_to_user didn't copy everything (err %d, cmd %u)",
|
||||||
|
@@ -227,7 +227,7 @@ static ssize_t dlmfs_file_read(struct file *filp,
|
|||||||
loff_t *ppos)
|
loff_t *ppos)
|
||||||
{
|
{
|
||||||
int bytes_left;
|
int bytes_left;
|
||||||
ssize_t readlen, got;
|
ssize_t got;
|
||||||
char *lvb_buf;
|
char *lvb_buf;
|
||||||
struct inode *inode = file_inode(filp);
|
struct inode *inode = file_inode(filp);
|
||||||
|
|
||||||
@@ -237,36 +237,31 @@ static ssize_t dlmfs_file_read(struct file *filp,
|
|||||||
if (*ppos >= i_size_read(inode))
|
if (*ppos >= i_size_read(inode))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
/* don't read past the lvb */
|
||||||
|
if (count > i_size_read(inode) - *ppos)
|
||||||
|
count = i_size_read(inode) - *ppos;
|
||||||
|
|
||||||
if (!count)
|
if (!count)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!access_ok(buf, count))
|
lvb_buf = kmalloc(count, GFP_NOFS);
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
/* don't read past the lvb */
|
|
||||||
if ((count + *ppos) > i_size_read(inode))
|
|
||||||
readlen = i_size_read(inode) - *ppos;
|
|
||||||
else
|
|
||||||
readlen = count;
|
|
||||||
|
|
||||||
lvb_buf = kmalloc(readlen, GFP_NOFS);
|
|
||||||
if (!lvb_buf)
|
if (!lvb_buf)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
got = user_dlm_read_lvb(inode, lvb_buf, readlen);
|
got = user_dlm_read_lvb(inode, lvb_buf, count);
|
||||||
if (got) {
|
if (got) {
|
||||||
BUG_ON(got != readlen);
|
BUG_ON(got != count);
|
||||||
bytes_left = __copy_to_user(buf, lvb_buf, readlen);
|
bytes_left = copy_to_user(buf, lvb_buf, count);
|
||||||
readlen -= bytes_left;
|
count -= bytes_left;
|
||||||
} else
|
} else
|
||||||
readlen = 0;
|
count = 0;
|
||||||
|
|
||||||
kfree(lvb_buf);
|
kfree(lvb_buf);
|
||||||
|
|
||||||
*ppos = *ppos + readlen;
|
*ppos = *ppos + count;
|
||||||
|
|
||||||
mlog(0, "read %zd bytes\n", readlen);
|
mlog(0, "read %zu bytes\n", count);
|
||||||
return readlen;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t dlmfs_file_write(struct file *filp,
|
static ssize_t dlmfs_file_write(struct file *filp,
|
||||||
|
Reference in New Issue
Block a user