Skip to content

Commit fdc81f4

Browse files
author
Al Viro
committed
sg_start_req(): use import_iovec()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 451a288 commit fdc81f4

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

Diff for: drivers/scsi/sg.c

+5-11
Original file line numberDiff line numberDiff line change
@@ -1744,21 +1744,15 @@ sg_start_req(Sg_request *srp, unsigned char *cmd)
17441744
md->from_user = 0;
17451745
}
17461746

1747-
if (unlikely(iov_count > MAX_UIOVEC))
1748-
return -EINVAL;
1749-
17501747
if (iov_count) {
1751-
int size = sizeof(struct iovec) * iov_count;
1752-
struct iovec *iov;
1748+
struct iovec *iov = NULL;
17531749
struct iov_iter i;
17541750

1755-
iov = memdup_user(hp->dxferp, size);
1756-
if (IS_ERR(iov))
1757-
return PTR_ERR(iov);
1751+
res = import_iovec(rw, hp->dxferp, iov_count, 0, &iov, &i);
1752+
if (res < 0)
1753+
return res;
17581754

1759-
iov_iter_init(&i, rw, iov, iov_count,
1760-
min_t(size_t, hp->dxfer_len,
1761-
iov_length(iov, iov_count)));
1755+
iov_iter_truncate(&i, hp->dxfer_len);
17621756

17631757
res = blk_rq_map_user_iov(q, rq, md, &i, GFP_ATOMIC);
17641758
kfree(iov);

0 commit comments

Comments
 (0)