From 53b670a75bef4bf6484bbf6ca6a896c365676fd4 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Mon, 15 Dec 2008 13:48:47 +0000 Subject: [PATCH] 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 Cc: Ian Abbott Cc: David Schleef Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 1464f550a5af..fbd3d1c6c647 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 -- 2.20.1