diff options
Diffstat (limited to 'drivers/scsi/sg.c')
-rw-r--r-- | drivers/scsi/sg.c | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index ffc87851f2e8..82312df9b0bf 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -1312,8 +1312,10 @@ static void sg_rq_end_io(struct request *rq, int uptodate) | |||
1312 | wake_up_interruptible(&sfp->read_wait); | 1312 | wake_up_interruptible(&sfp->read_wait); |
1313 | kill_fasync(&sfp->async_qp, SIGPOLL, POLL_IN); | 1313 | kill_fasync(&sfp->async_qp, SIGPOLL, POLL_IN); |
1314 | kref_put(&sfp->f_ref, sg_remove_sfp); | 1314 | kref_put(&sfp->f_ref, sg_remove_sfp); |
1315 | } else | 1315 | } else { |
1316 | execute_in_process_context(sg_rq_end_io_usercontext, &srp->ew); | 1316 | INIT_WORK(&srp->ew.work, sg_rq_end_io_usercontext); |
1317 | schedule_work(&srp->ew.work); | ||
1318 | } | ||
1317 | } | 1319 | } |
1318 | 1320 | ||
1319 | static struct file_operations sg_fops = { | 1321 | static struct file_operations sg_fops = { |
@@ -1656,10 +1658,30 @@ static int sg_start_req(Sg_request *srp, unsigned char *cmd) | |||
1656 | md->null_mapped = hp->dxferp ? 0 : 1; | 1658 | md->null_mapped = hp->dxferp ? 0 : 1; |
1657 | } | 1659 | } |
1658 | 1660 | ||
1659 | if (iov_count) | 1661 | if (iov_count) { |
1660 | res = blk_rq_map_user_iov(q, rq, md, hp->dxferp, iov_count, | 1662 | int len, size = sizeof(struct sg_iovec) * iov_count; |
1661 | hp->dxfer_len, GFP_ATOMIC); | 1663 | struct iovec *iov; |
1662 | else | 1664 | |
1665 | iov = kmalloc(size, GFP_ATOMIC); | ||
1666 | if (!iov) | ||
1667 | return -ENOMEM; | ||
1668 | |||
1669 | if (copy_from_user(iov, hp->dxferp, size)) { | ||
1670 | kfree(iov); | ||
1671 | return -EFAULT; | ||
1672 | } | ||
1673 | |||
1674 | len = iov_length(iov, iov_count); | ||
1675 | if (hp->dxfer_len < len) { | ||
1676 | iov_count = iov_shorten(iov, iov_count, hp->dxfer_len); | ||
1677 | len = hp->dxfer_len; | ||
1678 | } | ||
1679 | |||
1680 | res = blk_rq_map_user_iov(q, rq, md, (struct sg_iovec *)iov, | ||
1681 | iov_count, | ||
1682 | len, GFP_ATOMIC); | ||
1683 | kfree(iov); | ||
1684 | } else | ||
1663 | res = blk_rq_map_user(q, rq, md, hp->dxferp, | 1685 | res = blk_rq_map_user(q, rq, md, hp->dxferp, |
1664 | hp->dxfer_len, GFP_ATOMIC); | 1686 | hp->dxfer_len, GFP_ATOMIC); |
1665 | 1687 | ||
@@ -2079,7 +2101,8 @@ static void sg_remove_sfp(struct kref *kref) | |||
2079 | write_unlock_irqrestore(&sg_index_lock, iflags); | 2101 | write_unlock_irqrestore(&sg_index_lock, iflags); |
2080 | wake_up_interruptible(&sdp->o_excl_wait); | 2102 | wake_up_interruptible(&sdp->o_excl_wait); |
2081 | 2103 | ||
2082 | execute_in_process_context(sg_remove_sfp_usercontext, &sfp->ew); | 2104 | INIT_WORK(&sfp->ew.work, sg_remove_sfp_usercontext); |
2105 | schedule_work(&sfp->ew.work); | ||
2083 | } | 2106 | } |
2084 | 2107 | ||
2085 | static int | 2108 | static int |