From 67d294c65eb71b4263eee238e6ad51c946b725bb Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Mon, 15 Dec 2008 13:44:45 +0000 Subject: [PATCH] Added some validation of comedi module parameter values. --- comedi/comedi_fops.c | 13 +++++++++++++ include/linux/comedidev.h | 1 - 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/comedi/comedi_fops.c b/comedi/comedi_fops.c index c284d9d3..be1f2175 100644 --- a/comedi/comedi_fops.c +++ b/comedi/comedi_fops.c @@ -1911,6 +1911,19 @@ static int __init comedi_init(void) printk("comedi: version " COMEDI_RELEASE " - http://www.comedi.org\n"); + if(comedi_num_legacy_minors < 0 || comedi_num_legacy_minors > COMEDI_NUM_BOARD_MINORS) + { + printk("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); retval = register_chrdev_region(MKDEV(COMEDI_MAJOR, 0), diff --git a/include/linux/comedidev.h b/include/linux/comedidev.h index 5763abc1..74d6cb4e 100644 --- a/include/linux/comedidev.h +++ b/include/linux/comedidev.h @@ -121,7 +121,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 -- 2.26.2