diff options
author | Frank Mori Hess <fmhess@users.sourceforge.net> | 2008-12-15 13:48:47 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-04-03 21:53:52 (GMT) |
commit | 53b670a75bef4bf6484bbf6ca6a896c365676fd4 (patch) | |
tree | a379b1ac4aab872cc41b4718ff0919aaf9785724 | |
parent | a3cb729ef4a192f04179f780122df78ef1ffe779 (diff) | |
download | linux-fsl-qoriq-53b670a75bef4bf6484bbf6ca6a896c365676fd4.tar.xz |
Staging: comedi: fix bug with invalid minor number usage.
Return error instead of segfaulting if user trys to run comedi_config on
a device file with and invalid minor number.
From: Frank Mori Hess <fmhess@users.sourceforge.net>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: David Schleef <ds@schleef.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/staging/comedi/comedi_fops.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 1464f55..fbd3d1c 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -104,9 +104,13 @@ static int comedi_ioctl(struct inode *inode, struct file *file, const unsigned minor = iminor(file->f_dentry->d_inode); struct comedi_device_file_info *dev_file_info = comedi_get_device_file_info(minor); - comedi_device *dev = dev_file_info->device; + comedi_device *dev; int rc; + if (dev_file_info == NULL || dev_file_info->device == NULL) + return -ENODEV; + dev = dev_file_info->device; + mutex_lock(&dev->mutex); /* Device config is special, because it must work on |