From: Frank Mori Hess Date: Mon, 15 Dec 2008 13:48:47 +0000 (+0000) Subject: Staging: comedi: fix bug with invalid minor number usage. X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=53b670a75bef4bf6484bbf6ca6a896c365676fd4;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git 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 --- 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