diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2015-03-21 20:25:30 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-04-11 22:27:14 -0400 |
commit | fdc81f45e9f57858da6351836507fbcf1b7583ee (patch) | |
tree | 3f7e4ec5af122eccf85ab526ad01e8df01848f2b /drivers | |
parent | 451a2886b6bf90e2fb378f7c46c655450fb96e81 (diff) |
sg_start_req(): use import_iovec()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/sg.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index b5a4db883223..9d7b7db75e4b 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -1744,21 +1744,15 @@ sg_start_req(Sg_request *srp, unsigned char *cmd) | |||
1744 | md->from_user = 0; | 1744 | md->from_user = 0; |
1745 | } | 1745 | } |
1746 | 1746 | ||
1747 | if (unlikely(iov_count > MAX_UIOVEC)) | ||
1748 | return -EINVAL; | ||
1749 | |||
1750 | if (iov_count) { | 1747 | if (iov_count) { |
1751 | int size = sizeof(struct iovec) * iov_count; | 1748 | struct iovec *iov = NULL; |
1752 | struct iovec *iov; | ||
1753 | struct iov_iter i; | 1749 | struct iov_iter i; |
1754 | 1750 | ||
1755 | iov = memdup_user(hp->dxferp, size); | 1751 | res = import_iovec(rw, hp->dxferp, iov_count, 0, &iov, &i); |
1756 | if (IS_ERR(iov)) | 1752 | if (res < 0) |
1757 | return PTR_ERR(iov); | 1753 | return res; |
1758 | 1754 | ||
1759 | iov_iter_init(&i, rw, iov, iov_count, | 1755 | iov_iter_truncate(&i, hp->dxfer_len); |
1760 | min_t(size_t, hp->dxfer_len, | ||
1761 | iov_length(iov, iov_count))); | ||
1762 | 1756 | ||
1763 | res = blk_rq_map_user_iov(q, rq, md, &i, GFP_ATOMIC); | 1757 | res = blk_rq_map_user_iov(q, rq, md, &i, GFP_ATOMIC); |
1764 | kfree(iov); | 1758 | kfree(iov); |