staging: comedi: verify array index is correct before using it
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 9 Jul 2020 10:29:36 +0000 (13:29 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Jul 2020 07:34:08 +0000 (09:34 +0200)
commit4b32f8dbb8c9fdec9c63f36db961ce07dcf64bab
tree7a8edec7b5c88cea3e3b54e866ecb617d99894af
parentc796ed3590463c467efa2b9241bce25389c321be
staging: comedi: verify array index is correct before using it

[ Upstream commit ef75e14a6c935eec82abac07ab68e388514e39bc ]

This code reads from the array before verifying that "trig" is a valid
index.  If the index is wildly out of bounds then reading from an
invalid address could lead to an Oops.

Fixes: a8c66b684efa ("staging: comedi: addi_apci_1500: rewrite the subdevice support functions")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Link: https://lore.kernel.org/r/20200709102936.GA20875@mwanda
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/staging/comedi/drivers/addi_apci_1500.c