comedi: Add/fix sanity check in ISA drivers to avoid null-ptr-deref

From: Ian Abbott

Date: Thu Jun 18 2026 - 06:37:38 EST


As reported in [1], several comedi ISA drivers register their interrupt
handler before initializing the subdevice the handler uses which could
result in null pointer dereferences if the device raises an interrupt
prematurely.

A common way to avoid that in the comedi drivers is to check the device
is fully set up by testing the dev->attached flag (where dev is a
pointer to the struct comedi_device that is the context for the
interrupt handler), so add that test to some drivers that need it. Some
drivers already do the test, but do it after a potential null pointer
dereference, so the code needs reordering to avoid that.

The report mentions the aio_iiro_16, comedi_parport, das6402,
ni_atmio16d, pcm711, and pcmmio drivers. I already sent a patch for
comedi_parport about 3 weeks ago [2], but this patch series also patches
the dt2811, ni_at_a2150, pcm816, pcm818, pcmuio, and quatech_daqp_cs
drivers.

[1] https://lore.kernel.org/lkml/20260610115912.780131-1-jjy600901@xxxxxxxxx/
[2] https://lore.kernel.org/lkml/20260527125104.96596-1-abbotti@xxxxxxxxx/

1) comedi: aio_iiro_16: Add sanity check to interrupt handler
2) comedi: das6402: Add sanity check to interrupt handler
3) comedi: dt2811: Fix sanity check in interrupt handler
4) comedi: ni_at_a2150: Fix sanity check in interrupt handler
5) comedi: ni_atmio16d: Add sanity check to interrupt handler
6) comedi: pcm711: Fix sanity check in interrupt handler
7) comedi: pcm816: Fix sanity check in interrupt handler
8) comedi: pcm818: Fix sanity check in interrupt handler
9) comedi: pcmmio: Add sanity check to interrupt handler
10) comedi: pcmuio: Add sanity check to interrupt handler
11) comedi: quatech_daqp_cs: Fix sanity check in interrupt handler

drivers/comedi/drivers/aio_iiro_16.c | 3 +++
drivers/comedi/drivers/das6402.c | 10 ++++++++--
drivers/comedi/drivers/dt2811.c | 7 +++++--
drivers/comedi/drivers/ni_at_a2150.c | 13 +++++++++----
drivers/comedi/drivers/ni_atmio16d.c | 3 +++
drivers/comedi/drivers/pcl711.c | 3 ++-
drivers/comedi/drivers/pcl816.c | 3 ++-
drivers/comedi/drivers/pcl818.c | 3 ++-
drivers/comedi/drivers/pcmmio.c | 3 +++
drivers/comedi/drivers/pcmuio.c | 5 ++++-
drivers/comedi/drivers/quatech_daqp_cs.c | 4 +++-
11 files changed, 44 insertions(+), 13 deletions(-)