From e7dca1c50b452ee2527c4cc10cf53240d595291b Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Mon, 15 Dec 2008 13:48:47 +0000 Subject: [PATCH] Return error instead of segfaulting if user trys to run comedi_config on a device file with and invalid minor number. --- comedi/comedi_fops.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/comedi/comedi_fops.c b/comedi/comedi_fops.c index be1f2175..8e976a6d 100644 --- a/comedi/comedi_fops.c +++ b/comedi/comedi_fops.c @@ -102,9 +102,12 @@ 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 -- 2.26.2