1
0
Fork 0
alistair23-linux/drivers/staging/comedi
Ian Abbott 9fea3a40f6 staging: comedi: ni_routes: allow partial routing information
This patch fixes a regression on setting up asynchronous commands to use
external trigger sources when board-specific routing information is
missing.

`ni_find_device_routes()` (called via `ni_assign_device_routes()`) finds
the table of register values for the device family and the set of valid
routes for the specific board.  If both are found,
`tables->route_values` is set to point to the table of register values
for the device family and `tables->valid_routes` is set to point to the
list of valid routes for the specific board.  If either is not found,
both `tables->route_values` and `tables->valid_routes` are left set at
their initial null values (initialized by `ni_assign_device_routes()`)
and the function returns `-ENODATA`.

Returning an error results in some routing functionality being disabled.
Unfortunately, leaving `table->route_values` set to `NULL` also breaks
the setting up of asynchronous commands that are configured to use
external trigger sources.  Calls to `ni_check_trigger_arg()` or
`ni_check_trigger_arg_roffs()` while checking the asynchronous command
set-up would result in a null pointer dereference if
`table->route_values` is `NULL`.  The null pointer dereference is fixed
in another patch, but it now results in failure to set up the
asynchronous command.  That is a regression from the behavior prior to
commit 347e244884 ("staging: comedi: tio: implement global tio/ctr
routing") and commit 56d0b826d3 ("staging: comedi: ni_mio_common:
implement new routing for TRIG_EXT").

Change `ni_find_device_routes()` to set `tables->route_values` and/or
`tables->valid_routes` to valid information even if the other one can
only be set to `NULL` due to missing information.  The function will
still return an error in that case.  This should result in
`tables->valid_routes` being valid for all currently supported device
families even if the board-specific routing information is missing.
That should be enough to fix the regression on setting up asynchronous
commands to use external triggers for boards with missing routing
information.

Fixes: 347e244884 ("staging: comedi: tio: implement global tio/ctr routing")
Fixes: 56d0b826d3 ("staging: comedi: ni_mio_common: implement new routing for TRIG_EXT").
Cc: <stable@vger.kernel.org> # 4.20+
Cc: Spencer E. Olson <olsonse@umich.edu>
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Link: https://lore.kernel.org/r/20200114182532.132058-3-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-01-15 13:30:09 +01:00
..
drivers staging: comedi: ni_routes: allow partial routing information 2020-01-15 13:30:09 +01:00
kcomedilib staging: add missing SPDX lines to Makefile files 2019-04-03 11:10:15 +02:00
Kconfig staging: comedi: use help instead of ---help--- in Kconfig 2019-04-19 15:01:50 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
TODO comedi: note a coverity discovered hole that needs fixing 2016-03-05 14:56:55 -08:00
comedi.h staging: comedi: clarify/unify macros for NI macro-defined terminals 2018-11-07 13:08:28 +01:00
comedi_buf.c staging: comedi: use dma_mmap_coherent for DMA-able buffer mmap 2019-06-26 09:32:13 +08:00
comedi_compat32.c Remove 'type' argument from access_ok() function 2019-01-03 18:57:57 -08:00
comedi_compat32.h Staging: comedi: comedi_compat32.h: fixed missing or malformed SPDX-License-Identifier 2018-06-18 10:55:11 +02:00
comedi_fops.c staging: comedi: use dma_mmap_coherent for DMA-able buffer mmap 2019-06-26 09:32:13 +08:00
comedi_internal.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
comedi_pci.c staging: comedi: Remove redundant license text 2017-11-28 13:20:46 +01:00
comedi_pci.h Staging: comedi: comedi_pci.h: fixed missing or malformed SPDX-License-Identifier 2018-06-18 10:55:11 +02:00
comedi_pcmcia.c staging: comedi: Remove redundant license text 2017-11-28 13:20:46 +01:00
comedi_pcmcia.h Staging: comedi: comedi_pcmcia.h: fixed missing or malformed SPDX-License-Identifier 2018-06-18 10:55:11 +02:00
comedi_usb.c staging: comedi: Remove redundant license text 2017-11-28 13:20:46 +01:00
comedi_usb.h staging: comedi: comedi_usb.h: SPDX License Identifier is added in the first line 2018-05-31 19:00:53 +02:00
comedidev.h staging: comedi: ni_mio_common: Fix divide-by-zero for DIO cmdtest 2019-03-18 07:57:58 +01:00
comedilib.h Staging: comedi: comedilib.h: fixed missing or malformed SPDX-License-Identifier 2018-06-18 10:55:11 +02:00
drivers.c staging: comedi: Add lockdep_assert_held() calls for dev->attach_lock 2019-04-19 14:33:41 +02:00
proc.c proc: introduce proc_create_single{,_data} 2018-05-16 07:23:35 +02:00
range.c staging: comedi: Remove redundant license text 2017-11-28 13:20:46 +01:00