summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Mori Hess <fmhess@users.sourceforge.net>2008-12-15 13:44:45 (GMT)
committerGreg Kroah-Hartman <gregkh@suse.de>2009-04-03 21:53:52 (GMT)
commita3cb729ef4a192f04179f780122df78ef1ffe779 (patch)
tree086bf22cf7404c7604d205224d00b2e952158553
parent4c41f3ae3bf0bcc53f259b657c2fbc3961ff2b8a (diff)
downloadlinux-fsl-qoriq-a3cb729ef4a192f04179f780122df78ef1ffe779.tar.xz
Staging: comedi: Added some validation of comedi module parameter values.
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.c16
-rw-r--r--drivers/staging/comedi/comedidev.h1
2 files changed, 16 insertions, 1 deletions
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index ed9f2bb..1464f55 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -1911,6 +1911,22 @@ static int __init comedi_init(void)
printk(KERN_INFO "comedi: version " COMEDI_RELEASE
" - http://www.comedi.org\n");
+ if (comedi_num_legacy_minors < 0 ||
+ comedi_num_legacy_minors > COMEDI_NUM_BOARD_MINORS) {
+ printk(KERN_ERR "comedi: error: invalid value for module "
+ "parameter \"comedi_num_legacy_minors\". Valid values "
+ "are 0 through %i.\n", COMEDI_NUM_BOARD_MINORS);
+ return -EINVAL;
+ }
+
+ /*
+ * comedi is unusable if both comedi_autoconfig and
+ * comedi_num_legacy_minors are zero, so we might as well adjust the
+ * defaults in that case
+ */
+ if (comedi_autoconfig == 0 && comedi_num_legacy_minors == 0)
+ comedi_num_legacy_minors = 16;
+
memset(comedi_file_info_table, 0,
sizeof(struct comedi_device_file_info *) * COMEDI_NUM_MINORS);
diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h
index 6d67c48..9a56c0e 100644
--- a/drivers/staging/comedi/comedidev.h
+++ b/drivers/staging/comedi/comedidev.h
@@ -119,7 +119,6 @@
#define PCI_VENDOR_ID_MEILHAUS 0x1402
#define COMEDI_NUM_MINORS 0x100
-#define COMEDI_NUM_LEGACY_MINORS 0x10
#define COMEDI_NUM_BOARD_MINORS 0x30
#define COMEDI_FIRST_SUBDEVICE_MINOR COMEDI_NUM_BOARD_MINORS