aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--block/scsi_ioctl.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index e1f71c396193..55b6f15dac90 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -335,16 +335,14 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
335 struct iov_iter i; 335 struct iov_iter i;
336 struct iovec *iov = NULL; 336 struct iovec *iov = NULL;
337 337
338 ret = rw_copy_check_uvector(-1, hdr->dxferp, hdr->iovec_count, 338 ret = import_iovec(rq_data_dir(rq),
339 0, NULL, &iov); 339 hdr->dxferp, hdr->iovec_count,
340 if (ret < 0) { 340 0, &iov, &i);
341 kfree(iov); 341 if (ret < 0)
342 goto out_free_cdb; 342 goto out_free_cdb;
343 }
344 343
345 /* SG_IO howto says that the shorter of the two wins */ 344 /* SG_IO howto says that the shorter of the two wins */
346 iov_iter_init(&i, rq_data_dir(rq), iov, hdr->iovec_count, 345 iov_iter_truncate(&i, hdr->dxfer_len);
347 min_t(unsigned, ret, hdr->dxfer_len));
348 346
349 ret = blk_rq_map_user_iov(q, rq, NULL, &i, GFP_KERNEL); 347 ret = blk_rq_map_user_iov(q, rq, NULL, &i, GFP_KERNEL);
350 kfree(iov); 348 kfree(iov);