Commit 32a56afa authored by Al Viro's avatar Al Viro

aio_setup_vectored_rw(): switch to {compat_,}import_iovec()

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 345995fa
...@@ -1357,23 +1357,14 @@ static int aio_setup_vectored_rw(int rw, char __user *buf, size_t len, ...@@ -1357,23 +1357,14 @@ static int aio_setup_vectored_rw(int rw, char __user *buf, size_t len,
bool compat, bool compat,
struct iov_iter *iter) struct iov_iter *iter)
{ {
ssize_t ret;
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
if (compat) if (compat)
ret = compat_rw_copy_check_uvector(rw, return compat_import_iovec(rw,
(struct compat_iovec __user *)buf, (struct compat_iovec __user *)buf,
len, UIO_FASTIOV, *iovec, iovec); len, UIO_FASTIOV, iovec, iter);
else
#endif #endif
ret = rw_copy_check_uvector(rw, return import_iovec(rw, (struct iovec __user *)buf,
(struct iovec __user *)buf, len, UIO_FASTIOV, iovec, iter);
len, UIO_FASTIOV, *iovec, iovec);
if (ret < 0)
return ret;
iov_iter_init(iter, rw, *iovec, len, ret);
return 0;
} }
/* /*
...@@ -1418,13 +1409,14 @@ static ssize_t aio_run_iocb(struct kiocb *req, unsigned opcode, ...@@ -1418,13 +1409,14 @@ static ssize_t aio_run_iocb(struct kiocb *req, unsigned opcode,
if (opcode == IOCB_CMD_PREADV || opcode == IOCB_CMD_PWRITEV) if (opcode == IOCB_CMD_PREADV || opcode == IOCB_CMD_PWRITEV)
ret = aio_setup_vectored_rw(rw, buf, len, ret = aio_setup_vectored_rw(rw, buf, len,
&iovec, compat, &iter); &iovec, compat, &iter);
else else {
ret = import_single_range(rw, buf, len, iovec, &iter); ret = import_single_range(rw, buf, len, iovec, &iter);
iovec = NULL;
}
if (!ret) if (!ret)
ret = rw_verify_area(rw, file, &req->ki_pos, ret = rw_verify_area(rw, file, &req->ki_pos,
iov_iter_count(&iter)); iov_iter_count(&iter));
if (ret < 0) { if (ret < 0) {
if (iovec != inline_vecs)
kfree(iovec); kfree(iovec);
return ret; return ret;
} }
...@@ -1449,6 +1441,7 @@ static ssize_t aio_run_iocb(struct kiocb *req, unsigned opcode, ...@@ -1449,6 +1441,7 @@ static ssize_t aio_run_iocb(struct kiocb *req, unsigned opcode,
if (rw == WRITE) if (rw == WRITE)
file_end_write(file); file_end_write(file);
kfree(iovec);
break; break;
case IOCB_CMD_FDSYNC: case IOCB_CMD_FDSYNC:
...@@ -1470,9 +1463,6 @@ static ssize_t aio_run_iocb(struct kiocb *req, unsigned opcode, ...@@ -1470,9 +1463,6 @@ static ssize_t aio_run_iocb(struct kiocb *req, unsigned opcode,
return -EINVAL; return -EINVAL;
} }
if (iovec != inline_vecs)
kfree(iovec);
if (ret != -EIOCBQUEUED) { if (ret != -EIOCBQUEUED) {
/* /*
* There's no easy way to restart the syscall since other AIO's * There's no easy way to restart the syscall since other AIO's
......
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