Skip to content

Commit 062ea67

Browse files
committed
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()
2 parents 56446ef + 0702e4f commit 062ea67

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

drivers/scsi/esas2r/esas2r_ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1510,7 +1510,7 @@ int esas2r_ioctl_handler(void *hostdata, unsigned int cmd, void __user *arg)
15101510
}
15111511

15121512
/* Always copy the buffer back, if only to pick up the status */
1513-
err = __copy_to_user(arg, ioctl, sizeof(struct atto_express_ioctl));
1513+
err = copy_to_user(arg, ioctl, sizeof(struct atto_express_ioctl));
15141514
if (err != 0) {
15151515
esas2r_log(ESAS2R_LOG_WARN,
15161516
"ioctl_handler copy_to_user didn't copy everything (err %d, cmd %u)",

fs/ocfs2/dlmfs/dlmfs.c

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ static ssize_t dlmfs_file_read(struct file *filp,
227227
loff_t *ppos)
228228
{
229229
int bytes_left;
230-
ssize_t readlen, got;
230+
ssize_t got;
231231
char *lvb_buf;
232232
struct inode *inode = file_inode(filp);
233233

@@ -237,36 +237,31 @@ static ssize_t dlmfs_file_read(struct file *filp,
237237
if (*ppos >= i_size_read(inode))
238238
return 0;
239239

240+
/* don't read past the lvb */
241+
if (count > i_size_read(inode) - *ppos)
242+
count = i_size_read(inode) - *ppos;
243+
240244
if (!count)
241245
return 0;
242246

243-
if (!access_ok(buf, count))
244-
return -EFAULT;
245-
246-
/* don't read past the lvb */
247-
if ((count + *ppos) > i_size_read(inode))
248-
readlen = i_size_read(inode) - *ppos;
249-
else
250-
readlen = count;
251-
252-
lvb_buf = kmalloc(readlen, GFP_NOFS);
247+
lvb_buf = kmalloc(count, GFP_NOFS);
253248
if (!lvb_buf)
254249
return -ENOMEM;
255250

256-
got = user_dlm_read_lvb(inode, lvb_buf, readlen);
251+
got = user_dlm_read_lvb(inode, lvb_buf, count);
257252
if (got) {
258-
BUG_ON(got != readlen);
259-
bytes_left = __copy_to_user(buf, lvb_buf, readlen);
260-
readlen -= bytes_left;
253+
BUG_ON(got != count);
254+
bytes_left = copy_to_user(buf, lvb_buf, count);
255+
count -= bytes_left;
261256
} else
262-
readlen = 0;
257+
count = 0;
263258

264259
kfree(lvb_buf);
265260

266-
*ppos = *ppos + readlen;
261+
*ppos = *ppos + count;
267262

268-
mlog(0, "read %zd bytes\n", readlen);
269-
return readlen;
263+
mlog(0, "read %zu bytes\n", count);
264+
return count;
270265
}
271266

272267
static ssize_t dlmfs_file_write(struct file *filp,

0 commit comments

Comments
 (0)