mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
staging: comedi: fix oops for USB DAQ devices.
This fixes kernel oops when an USB DAQ device is plugged out while it's communicating with the userspace software. Signed-off-by: Bernd Porr <berndporr@f2s.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
8b78607fc4
commit
3ffab428f4
@ -1452,9 +1452,6 @@ static struct vm_operations_struct comedi_vm_ops = {
|
||||
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;
|
||||
@ -1462,6 +1459,15 @@ static int comedi_mmap(struct file *file, struct vm_area_struct *vma)
|
||||
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) {
|
||||
@ -1528,11 +1534,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) {
|
||||
@ -1578,9 +1590,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);
|
||||
@ -1683,9 +1701,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);
|
||||
@ -1885,11 +1909,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);
|
||||
|
||||
@ -1923,10 +1953,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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user