staging: comedi: vmk80xx: sanity check context used to get the boardinfo
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Thu, 18 Jun 2015 17:54:57 +0000 (10:54 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 19 Jun 2015 04:19:03 +0000 (21:19 -0700)
As done in all the comedi drivers that auto attach, sanity check the
passed context that is used to get the boardinfo.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/vmk80xx.c

index a87b152..3af075a 100644 (file)
@@ -795,7 +795,10 @@ static int vmk80xx_auto_attach(struct comedi_device *dev,
        struct vmk80xx_private *devpriv;
        int ret;
 
-       board = &vmk80xx_boardinfo[context];
+       if (context < ARRAY_SIZE(vmk80xx_boardinfo))
+               board = &vmk80xx_boardinfo[context];
+       if (!board)
+               return -ENODEV;
        dev->board_ptr = board;
        dev->board_name = board->name;