From 7984dcc87eed9b48fed2092822e94abe7919a07e Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Sun, 11 Dec 2005 21:41:27 +0000 Subject: [PATCH] Fixed array overrun for boards with more than 2 ao channels. --- comedi/drivers/ni_mio_common.c | 6 ++++++ comedi/drivers/ni_stc.h | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/comedi/drivers/ni_mio_common.c b/comedi/drivers/ni_mio_common.c index ded65878..51a3af7b 100644 --- a/comedi/drivers/ni_mio_common.c +++ b/comedi/drivers/ni_mio_common.c @@ -2675,6 +2675,12 @@ static int ni_E_init(comedi_device *dev,comedi_devconfig *it) comedi_subdevice *s; int bits; + if(boardtype.n_aochan > MAX_N_AO_CHAN) + { + printk("bug! boardtype.n_aochan > MAX_N_AO_CHAN\n"); + return -EINVAL; + } + if(alloc_subdevices(dev, 10) < 0) return -ENOMEM; diff --git a/comedi/drivers/ni_stc.h b/comedi/drivers/ni_stc.h index adeb9040..5e3a726c 100644 --- a/comedi/drivers/ni_stc.h +++ b/comedi/drivers/ni_stc.h @@ -913,6 +913,8 @@ static ni_board ni_boards[]; #define boardtype (*(ni_board *)dev->board_ptr) +#define MAX_N_AO_CHAN 8 + #define NI_PRIVATE_COMMON \ unsigned short dio_output; \ unsigned short dio_control; \ @@ -932,12 +934,12 @@ static ni_board ni_boards[]; unsigned int changain_spec; \ \ unsigned int caldac_maxdata_list[MAX_N_CALDACS]; \ - unsigned short ao[2]; \ + unsigned short ao[MAX_N_AO_CHAN]; \ unsigned short caldacs[MAX_N_CALDACS]; \ \ volatile unsigned short ai_cmd2; \ \ - unsigned short ao_conf[2]; \ + unsigned short ao_conf[MAX_N_AO_CHAN]; \ unsigned short ao_mode1; \ unsigned short ao_mode2; \ unsigned short ao_mode3; \ -- 2.26.2