[PATCH] staging: comedi: addi_apci_1500: fix array access out of bounds error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The private data 'pm', 'pt', and 'pp' array members hold the trigger mode
parameters for ports A and B. Both ports are 8-bits and the arrays are 16-bits.
Array index 0 defines the AND mode and index 1 the OR mode parameters for both
ports.

The valid triggers to start the async command are 0 to 3 which select the
AND/OR mode for each port.

The 'pb_trig' (the array index for port B) in apci1500_di_inttrig_start() is
incorrect and results in an index of 0 or 2. Fix the calc so that the correct
index (0/1) is used.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Reported-by: Asaf Vertz <asaf.vertz@xxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/drivers/addi_apci_1500.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c
index fc7db1d..f15aa1f 100644
--- a/drivers/staging/comedi/drivers/addi_apci_1500.c
+++ b/drivers/staging/comedi/drivers/addi_apci_1500.c
@@ -296,7 +296,7 @@ static int apci1500_di_inttrig_start(struct comedi_device *dev,
 	unsigned int pa_mode = Z8536_PAB_MODE_PMS_DISABLE;
 	unsigned int pb_mode = Z8536_PAB_MODE_PMS_DISABLE;
 	unsigned int pa_trig = trig_num & 0x01;
-	unsigned int pb_trig = trig_num & 0x02;
+	unsigned int pb_trig = (trig_num >> 1) & 0x01;
 	bool valid_trig = false;
 	unsigned int val;
 
-- 
2.0.3

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux