Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 143959
b: refs/heads/master
c: 25636e2
h: refs/heads/master
i:
  143957: d98a415
  143955: 0707c19
  143951: e11fd56
v: v3
  • Loading branch information
Tejun Heo authored and Jens Axboe committed Apr 22, 2009
1 parent f0a4020 commit 76f3084
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 23c560a99d78bddf5c251bfa97bce19e4da4b3f3
refs/heads/master: 25636e282fe95508cae96bb27f86407aef935817
13 changes: 12 additions & 1 deletion trunk/block/scsi_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,

if (hdr->iovec_count) {
const int size = sizeof(struct sg_iovec) * hdr->iovec_count;
size_t iov_data_len;
struct sg_iovec *iov;

iov = kmalloc(size, GFP_KERNEL);
Expand All @@ -304,8 +305,18 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
goto out;
}

/* SG_IO howto says that the shorter of the two wins */
iov_data_len = iov_length((struct iovec *)iov,
hdr->iovec_count);
if (hdr->dxfer_len < iov_data_len) {
hdr->iovec_count = iov_shorten((struct iovec *)iov,
hdr->iovec_count,
hdr->dxfer_len);
iov_data_len = hdr->dxfer_len;
}

ret = blk_rq_map_user_iov(q, rq, NULL, iov, hdr->iovec_count,
hdr->dxfer_len, GFP_KERNEL);
iov_data_len, GFP_KERNEL);
kfree(iov);
} else if (hdr->dxfer_len)
ret = blk_rq_map_user(q, rq, NULL, hdr->dxferp, hdr->dxfer_len,
Expand Down

0 comments on commit 76f3084

Please sign in to comment.