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: pcl726: Add sanity checks for I/O base address

The "pcl726" driver uses an admin-supplied configuration option
(`it->options[0]`) to configure the I/O port base address of various
analog output ISA boards from Advantech (PCL-726/727/728) and ADLINK
(ACL-6126/6128). (Most of them also have digital I/O.) It currently
allows any base address to be configured but the hardware only supports
base addresses (configured by on-board DIP switches) from 0 or 0x200 up
to nearly 0x3FF, 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_len` 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-35-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ian Abbott and committed by
Greg Kroah-Hartman
588b6ffa b9723ebe

+10 -2
+10 -2
drivers/comedi/drivers/pcl726.c
··· 91 91 92 92 struct pcl726_board { 93 93 const char *name; 94 - unsigned long io_len; 94 + unsigned int io_len; 95 + unsigned int min_io_start; 95 96 unsigned int irq_mask; 96 97 const struct comedi_lrange *const *ao_ranges; 97 98 int ao_num_ranges; ··· 105 104 { 106 105 .name = "pcl726", 107 106 .io_len = 0x10, 107 + .min_io_start = 0x200, 108 108 .ao_ranges = &rangelist_726[0], 109 109 .ao_num_ranges = ARRAY_SIZE(rangelist_726), 110 110 .ao_nchan = 6, ··· 113 111 }, { 114 112 .name = "pcl727", 115 113 .io_len = 0x20, 114 + .min_io_start = 0x200, 116 115 .ao_ranges = &rangelist_727[0], 117 116 .ao_num_ranges = ARRAY_SIZE(rangelist_727), 118 117 .ao_nchan = 12, ··· 122 119 }, { 123 120 .name = "pcl728", 124 121 .io_len = 0x08, 122 + .min_io_start = 0, 125 123 .ao_num_ranges = ARRAY_SIZE(rangelist_728), 126 124 .ao_ranges = &rangelist_728[0], 127 125 .ao_nchan = 2, 128 126 }, { 129 127 .name = "acl6126", 130 128 .io_len = 0x10, 129 + .min_io_start = 0x200, 131 130 .irq_mask = 0x96e8, 132 131 .ao_num_ranges = ARRAY_SIZE(rangelist_726), 133 132 .ao_ranges = &rangelist_726[0], ··· 138 133 }, { 139 134 .name = "acl6128", 140 135 .io_len = 0x08, 136 + .min_io_start = 0, 141 137 .ao_num_ranges = ARRAY_SIZE(rangelist_728), 142 138 .ao_ranges = &rangelist_728[0], 143 139 .ao_nchan = 2, ··· 322 316 int ret; 323 317 int i; 324 318 325 - ret = comedi_request_region(dev, it->options[0], board->io_len); 319 + ret = comedi_check_request_region(dev, it->options[0], board->io_len, 320 + board->min_io_start, 0x3ff, 321 + board->io_len); 326 322 if (ret) 327 323 return ret; 328 324