sg_start_req(): use import_iovec()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
451a2886b6
commit
fdc81f45e9
1 changed files with 5 additions and 11 deletions
|
@ -1744,21 +1744,15 @@ sg_start_req(Sg_request *srp, unsigned char *cmd)
|
||||||
md->from_user = 0;
|
md->from_user = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlikely(iov_count > MAX_UIOVEC))
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (iov_count) {
|
if (iov_count) {
|
||||||
int size = sizeof(struct iovec) * iov_count;
|
struct iovec *iov = NULL;
|
||||||
struct iovec *iov;
|
|
||||||
struct iov_iter i;
|
struct iov_iter i;
|
||||||
|
|
||||||
iov = memdup_user(hp->dxferp, size);
|
res = import_iovec(rw, hp->dxferp, iov_count, 0, &iov, &i);
|
||||||
if (IS_ERR(iov))
|
if (res < 0)
|
||||||
return PTR_ERR(iov);
|
return res;
|
||||||
|
|
||||||
iov_iter_init(&i, rw, iov, iov_count,
|
iov_iter_truncate(&i, hp->dxfer_len);
|
||||||
min_t(size_t, hp->dxfer_len,
|
|
||||||
iov_length(iov, iov_count)));
|
|
||||||
|
|
||||||
res = blk_rq_map_user_iov(q, rq, md, &i, GFP_ATOMIC);
|
res = blk_rq_map_user_iov(q, rq, md, &i, GFP_ATOMIC);
|
||||||
kfree(iov);
|
kfree(iov);
|
||||||
|
|
Loading…
Add table
Reference in a new issue