Skip to content

Commit

Permalink
Merge branch 'staging-linus' of git://git.kernel.org/pub/scm/linux/ke…
Browse files Browse the repository at this point in the history
…rnel/git/gregkh/staging

* 'staging-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging:
  Staging: comedi: fix integer overflow in do_insnlist_ioctl()
  Revert "Staging: comedi: integer overflow in do_insnlist_ioctl()"
  Staging: comedi: integer overflow in do_insnlist_ioctl()
  Staging: comedi: fix signal handling in read and write
  Staging: comedi: fix mmap_count
  staging: comedi: fix oops for USB DAQ devices.
  staging: comedi: usbduxsigma: Fixed wrong range for the analogue channel.
  staging:rts_pstor:Complete scanning_done variable
  staging: usbip: bugfix for deadlock
  • Loading branch information
torvalds committed Dec 2, 2011
2 parents ffb8fb5 + dfd8ee9 commit f9143ea
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 30 deletions.
96 changes: 73 additions & 23 deletions drivers/staging/comedi/comedi_fops.c
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ static int do_insnlist_ioctl(struct comedi_device *dev,
}

insns =
kmalloc(sizeof(struct comedi_insn) * insnlist.n_insns, GFP_KERNEL);
kcalloc(insnlist.n_insns, sizeof(struct comedi_insn), GFP_KERNEL);
if (!insns) {
DPRINTK("kmalloc failed\n");
ret = -ENOMEM;
Expand Down Expand Up @@ -1432,7 +1432,21 @@ static int do_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
return ret;
}

static void comedi_unmap(struct vm_area_struct *area)

static void comedi_vm_open(struct vm_area_struct *area)
{
struct comedi_async *async;
struct comedi_device *dev;

async = area->vm_private_data;
dev = async->subdevice->device;

mutex_lock(&dev->mutex);
async->mmap_count++;
mutex_unlock(&dev->mutex);
}

static void comedi_vm_close(struct vm_area_struct *area)
{
struct comedi_async *async;
struct comedi_device *dev;
Expand All @@ -1446,22 +1460,29 @@ static void comedi_unmap(struct vm_area_struct *area)
}

static struct vm_operations_struct comedi_vm_ops = {
.close = comedi_unmap,
.open = comedi_vm_open,
.close = comedi_vm_close,
};

static int comedi_mmap(struct file *file, struct vm_area_struct *vma)
{
const unsigned minor = iminor(file->f_dentry->d_inode);
struct comedi_device_file_info *dev_file_info =
comedi_get_device_file_info(minor);
struct comedi_device *dev = dev_file_info->device;
struct comedi_async *async = NULL;
unsigned long start = vma->vm_start;
unsigned long size;
int n_pages;
int i;
int retval;
struct comedi_subdevice *s;
struct comedi_device_file_info *dev_file_info;
struct comedi_device *dev;

dev_file_info = comedi_get_device_file_info(minor);
if (dev_file_info == NULL)
return -ENODEV;
dev = dev_file_info->device;
if (dev == NULL)
return -ENODEV;

mutex_lock(&dev->mutex);
if (!dev->attached) {
Expand Down Expand Up @@ -1528,11 +1549,17 @@ static unsigned int comedi_poll(struct file *file, poll_table * wait)
{
unsigned int mask = 0;
const unsigned minor = iminor(file->f_dentry->d_inode);
struct comedi_device_file_info *dev_file_info =
comedi_get_device_file_info(minor);
struct comedi_device *dev = dev_file_info->device;
struct comedi_subdevice *read_subdev;
struct comedi_subdevice *write_subdev;
struct comedi_device_file_info *dev_file_info;
struct comedi_device *dev;
dev_file_info = comedi_get_device_file_info(minor);

if (dev_file_info == NULL)
return -ENODEV;
dev = dev_file_info->device;
if (dev == NULL)
return -ENODEV;

mutex_lock(&dev->mutex);
if (!dev->attached) {
Expand Down Expand Up @@ -1578,9 +1605,15 @@ static ssize_t comedi_write(struct file *file, const char __user *buf,
int n, m, count = 0, retval = 0;
DECLARE_WAITQUEUE(wait, current);
const unsigned minor = iminor(file->f_dentry->d_inode);
struct comedi_device_file_info *dev_file_info =
comedi_get_device_file_info(minor);
struct comedi_device *dev = dev_file_info->device;
struct comedi_device_file_info *dev_file_info;
struct comedi_device *dev;
dev_file_info = comedi_get_device_file_info(minor);

if (dev_file_info == NULL)
return -ENODEV;
dev = dev_file_info->device;
if (dev == NULL)
return -ENODEV;

if (!dev->attached) {
DPRINTK("no driver configured on comedi%i\n", dev->minor);
Expand Down Expand Up @@ -1640,11 +1673,11 @@ static ssize_t comedi_write(struct file *file, const char __user *buf,
retval = -EAGAIN;
break;
}
schedule();
if (signal_pending(current)) {
retval = -ERESTARTSYS;
break;
}
schedule();
if (!s->busy)
break;
if (s->busy != file) {
Expand Down Expand Up @@ -1683,9 +1716,15 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
int n, m, count = 0, retval = 0;
DECLARE_WAITQUEUE(wait, current);
const unsigned minor = iminor(file->f_dentry->d_inode);
struct comedi_device_file_info *dev_file_info =
comedi_get_device_file_info(minor);
struct comedi_device *dev = dev_file_info->device;
struct comedi_device_file_info *dev_file_info;
struct comedi_device *dev;
dev_file_info = comedi_get_device_file_info(minor);

if (dev_file_info == NULL)
return -ENODEV;
dev = dev_file_info->device;
if (dev == NULL)
return -ENODEV;

if (!dev->attached) {
DPRINTK("no driver configured on comedi%i\n", dev->minor);
Expand Down Expand Up @@ -1741,11 +1780,11 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
retval = -EAGAIN;
break;
}
schedule();
if (signal_pending(current)) {
retval = -ERESTARTSYS;
break;
}
schedule();
if (!s->busy) {
retval = 0;
break;
Expand Down Expand Up @@ -1885,11 +1924,17 @@ static int comedi_open(struct inode *inode, struct file *file)
static int comedi_close(struct inode *inode, struct file *file)
{
const unsigned minor = iminor(inode);
struct comedi_device_file_info *dev_file_info =
comedi_get_device_file_info(minor);
struct comedi_device *dev = dev_file_info->device;
struct comedi_subdevice *s = NULL;
int i;
struct comedi_device_file_info *dev_file_info;
struct comedi_device *dev;
dev_file_info = comedi_get_device_file_info(minor);

if (dev_file_info == NULL)
return -ENODEV;
dev = dev_file_info->device;
if (dev == NULL)
return -ENODEV;

mutex_lock(&dev->mutex);

Expand Down Expand Up @@ -1923,10 +1968,15 @@ static int comedi_close(struct inode *inode, struct file *file)
static int comedi_fasync(int fd, struct file *file, int on)
{
const unsigned minor = iminor(file->f_dentry->d_inode);
struct comedi_device_file_info *dev_file_info =
comedi_get_device_file_info(minor);
struct comedi_device_file_info *dev_file_info;
struct comedi_device *dev;
dev_file_info = comedi_get_device_file_info(minor);

struct comedi_device *dev = dev_file_info->device;
if (dev_file_info == NULL)
return -ENODEV;
dev = dev_file_info->device;
if (dev == NULL)
return -ENODEV;

return fasync_helper(fd, file, on, &dev->async_queue);
}
Expand Down
7 changes: 4 additions & 3 deletions drivers/staging/comedi/drivers/usbduxsigma.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define DRIVER_VERSION "v0.5"
#define DRIVER_VERSION "v0.6"
#define DRIVER_AUTHOR "Bernd Porr, [email protected]"
#define DRIVER_DESC "Stirling/ITL USB-DUX SIGMA -- [email protected]"
/*
Expand All @@ -25,7 +25,7 @@ Driver: usbduxsigma
Description: University of Stirling USB DAQ & INCITE Technology Limited
Devices: [ITL] USB-DUX (usbduxsigma.o)
Author: Bernd Porr <[email protected]>
Updated: 21 Jul 2011
Updated: 8 Nov 2011
Status: testing
*/
/*
Expand All @@ -44,6 +44,7 @@ Status: testing
* 0.3: proper vendor ID and driver name
* 0.4: fixed D/A voltage range
* 0.5: various bug fixes, health check at startup
* 0.6: corrected wrong input range
*/

/* generates loads of debug info */
Expand Down Expand Up @@ -175,7 +176,7 @@ Status: testing
/* comedi constants */
static const struct comedi_lrange range_usbdux_ai_range = { 1, {
BIP_RANGE
(2.65)
(2.65/2.0)
}
};

Expand Down
1 change: 1 addition & 0 deletions drivers/staging/rts_pstor/rtsx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,7 @@ static int __devinit rtsx_probe(struct pci_dev *pci,
th = kthread_create(rtsx_scan_thread, dev, "rtsx-scan");
if (IS_ERR(th)) {
printk(KERN_ERR "Unable to start the device-scanning thread\n");
complete(&dev->scanning_done);
quiesce_and_remove_host(dev);
err = PTR_ERR(th);
goto errout;
Expand Down
10 changes: 6 additions & 4 deletions drivers/staging/usbip/vhci_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
{
struct usbip_device *ud = &vdev->ud;
struct urb *urb;
unsigned long flags;

spin_lock(&vdev->priv_lock);
urb = pickup_urb_and_free_priv(vdev, pdu->base.seqnum);
Expand Down Expand Up @@ -101,9 +102,9 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,

usbip_dbg_vhci_rx("now giveback urb %p\n", urb);

spin_lock(&the_controller->lock);
spin_lock_irqsave(&the_controller->lock, flags);
usb_hcd_unlink_urb_from_ep(vhci_to_hcd(the_controller), urb);
spin_unlock(&the_controller->lock);
spin_unlock_irqrestore(&the_controller->lock, flags);

usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, urb->status);

Expand Down Expand Up @@ -141,6 +142,7 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev,
{
struct vhci_unlink *unlink;
struct urb *urb;
unsigned long flags;

usbip_dump_header(pdu);

Expand Down Expand Up @@ -170,9 +172,9 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev,
urb->status = pdu->u.ret_unlink.status;
pr_info("urb->status %d\n", urb->status);

spin_lock(&the_controller->lock);
spin_lock_irqsave(&the_controller->lock, flags);
usb_hcd_unlink_urb_from_ep(vhci_to_hcd(the_controller), urb);
spin_unlock(&the_controller->lock);
spin_unlock_irqrestore(&the_controller->lock, flags);

usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb,
urb->status);
Expand Down

0 comments on commit f9143ea

Please sign in to comment.