Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 142125
b: refs/heads/master
c: 0fdf96b
h: refs/heads/master
i:
  142123: a924de6
v: v3
  • Loading branch information
FUJITA Tomonori authored and James Bottomley committed Apr 3, 2009
1 parent f5322e9 commit 86acb56
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 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: f894e74dc1983062d30d4e1b79bdb90b8a847f52
refs/heads/master: 0fdf96b67ac2649cc1ddb29b316a0db11586c6a8
28 changes: 24 additions & 4 deletions trunk/drivers/scsi/sg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1656,10 +1656,30 @@ static int sg_start_req(Sg_request *srp, unsigned char *cmd)
md->null_mapped = hp->dxferp ? 0 : 1;
}

if (iov_count)
res = blk_rq_map_user_iov(q, rq, md, hp->dxferp, iov_count,
hp->dxfer_len, GFP_ATOMIC);
else
if (iov_count) {
int len, size = sizeof(struct sg_iovec) * iov_count;
struct iovec *iov;

iov = kmalloc(size, GFP_ATOMIC);
if (!iov)
return -ENOMEM;

if (copy_from_user(iov, hp->dxferp, size)) {
kfree(iov);
return -EFAULT;
}

len = iov_length(iov, iov_count);
if (hp->dxfer_len < len) {
iov_count = iov_shorten(iov, iov_count, hp->dxfer_len);
len = hp->dxfer_len;
}

res = blk_rq_map_user_iov(q, rq, md, (struct sg_iovec *)iov,
iov_count,
len, GFP_ATOMIC);
kfree(iov);
} else
res = blk_rq_map_user(q, rq, md, hp->dxferp,
hp->dxfer_len, GFP_ATOMIC);

Expand Down

0 comments on commit 86acb56

Please sign in to comment.