]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
staging: comedi: dt282x: fix a null pointer deref on interrupt
authorIan Abbott <abbotti@mev.co.uk>
Wed, 26 Jun 2019 13:18:04 +0000 (14:18 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 21 Jul 2019 07:07:11 +0000 (09:07 +0200)
commit b8336be66dec06bef518030a0df9847122053ec5 upstream.

The interrupt handler `dt282x_interrupt()` causes a null pointer
dereference for those supported boards that have no analog output
support.  For these boards, `dev->write_subdev` will be `NULL` and
therefore the `s_ao` subdevice pointer variable will be `NULL`.  In that
case, the following call near the end of the interrupt handler results
in a null pointer dereference:

comedi_handle_events(dev, s_ao);

Fix it by only calling the above function if `s_ao` is valid.

(There are other uses of `s_ao` by the interrupt handler that may or may
not be reached depending on values of hardware registers.  Trust that
they are reliable for now.)

Note:
commit 4f6f009b204f ("staging: comedi: dt282x: use comedi_handle_events()")
propagates an earlier error from
commit f21c74fa4cfe ("staging: comedi: dt282x: use cfc_handle_events()").

Fixes: 4f6f009b204f ("staging: comedi: dt282x: use comedi_handle_events()")
Cc: <stable@vger.kernel.org> # v3.19+
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/dt282x.c

index b63472de761ab19267ce5a07b9efa20973ae523f..c62a1cc2b223b983b1c6b1913e49cc0a4b0b5de4 100644 (file)
@@ -553,7 +553,8 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
        }
 #endif
        comedi_handle_events(dev, s);
-       comedi_handle_events(dev, s_ao);
+       if (s_ao)
+               comedi_handle_events(dev, s_ao);
 
        return IRQ_RETVAL(handled);
 }