Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

comedi: pcl724: Add sanity checks for I/O base address

The "pcl724" driver uses an admin-supplied configuration option
(`it->options[0]`) to configure the I/O port base address of various
8255 chip-based digital I/O ISA boards from Advantech, ADLINK,
WinSystems, and Diamond Systems. It currently allows any base address
to be configured but the hardware only supports base addresses
(configured by on-board DIP switches or jumpers) in various ranges, and
on various alignment boundaries, depending on the model.

Store the minimum and maximum supported I/O address ranges in the static
board information array elements (the required alignment is already
stored in the `io_range` member), and add a sanity check to ensure the
device is not configured at an unsupported base address.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Link: https://patch.msgid.link/20260130170416.49994-34-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ian Abbott and committed by
Greg Kroah-Hartman
b9723ebe 7e33ddd6

+21 -1
+21 -1
drivers/comedi/drivers/pcl724.c
··· 31 31 struct pcl724_board { 32 32 const char *name; 33 33 unsigned int io_range; 34 + unsigned int min_io_start; 35 + unsigned int max_io_end; 34 36 unsigned int can_have96:1; 35 37 unsigned int is_pet48:1; 36 38 int numofports; ··· 42 40 { 43 41 .name = "pcl724", 44 42 .io_range = 0x04, 43 + .min_io_start = 0x200, 44 + .max_io_end = 0x3ff, 45 45 .numofports = 1, /* 24 DIO channels */ 46 46 }, { 47 47 .name = "pcl722", 48 48 .io_range = 0x20, 49 + .min_io_start = 0x200, 50 + .max_io_end = 0x3ff, 49 51 .can_have96 = 1, 50 52 .numofports = 6, /* 144 (or 96) DIO channels */ 51 53 }, { 52 54 .name = "pcl731", 53 55 .io_range = 0x08, 56 + .min_io_start = 0, 57 + .max_io_end = 0x3ff, 54 58 .numofports = 2, /* 48 DIO channels */ 55 59 }, { 56 60 .name = "acl7122", 57 61 .io_range = 0x20, 62 + .min_io_start = 0x200, 63 + .max_io_end = 0x3ff, 58 64 .can_have96 = 1, 59 65 .numofports = 6, /* 144 (or 96) DIO channels */ 60 66 }, { 61 67 .name = "acl7124", 62 68 .io_range = 0x04, 69 + .min_io_start = 0x200, 70 + .max_io_end = 0x3ff, 63 71 .numofports = 1, /* 24 DIO channels */ 64 72 }, { 65 73 .name = "pet48dio", 66 74 .io_range = 0x02, 75 + .min_io_start = 0, 76 + .max_io_end = 0x3ff, 67 77 .is_pet48 = 1, 68 78 .numofports = 2, /* 48 DIO channels */ 69 79 }, { 70 80 .name = "pcmio48", 71 81 .io_range = 0x08, 82 + .min_io_start = 0x100, 83 + .max_io_end = 0x17f, 72 84 .numofports = 2, /* 48 DIO channels */ 73 85 }, { 74 86 .name = "onyx-mm-dio", 75 87 .io_range = 0x10, 88 + .min_io_start = 0, 89 + .max_io_end = 0x3ff, 76 90 .numofports = 2, /* 48 DIO channels */ 77 91 }, 78 92 }; ··· 130 112 n_subdevices = 4; 131 113 } 132 114 133 - ret = comedi_request_region(dev, it->options[0], iorange); 115 + ret = comedi_check_request_region(dev, it->options[0], iorange, 116 + board->min_io_start, 117 + board->max_io_end, iorange); 134 118 if (ret) 135 119 return ret; 136 120