Added some validation of comedi module parameter values.
authorFrank Mori Hess <fmhess@speakeasy.net>
Mon, 15 Dec 2008 13:44:45 +0000 (13:44 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Mon, 15 Dec 2008 13:44:45 +0000 (13:44 +0000)
comedi/comedi_fops.c
include/linux/comedidev.h

index c284d9d366b49fbe8b5507244f222cf6b82f7e3e..be1f217530c27815aff0dc9a19981f1b59b3c702 100644 (file)
@@ -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),
index 5763abc1e77f3ca51d215e8d2d126c6cda2c0825..74d6cb4e4a1616baf972a3ede585a469edab5826 100644 (file)
 #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