diff options
| author | 2015-04-20 11:49:05 -0700 | |
|---|---|---|
| committer | 2015-04-30 17:15:59 +0200 | |
| commit | accb298fb2e3d09a84bd92595b115232f14a5e60 (patch) | |
| tree | af79f09e6893cb8c7b7178fbb25cb9a598169ee1 | |
| parent | staging: comedi: comedi_bond: fix 'b_mask' calc in bonding_dio_insn_bits() (diff) | |
staging: comedi: ni_nio_common: don't write non-existing caldac's
ni_write_caldac() checks the boardinfo 'caldac' array to determine what
caldac is used for a given 'addr'. It then calculates the 'bitstring' and
number of 'bits' used to write a value to that caldac address.
After checking the caldac array, if the number of bits is 0 there is no
caldac associated with the address. If this happens we shouldn't try
writing to the non-existing caldac.
Reported-by: coverity (CID 1192116)
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>
| -rw-r--r-- | drivers/staging/comedi/drivers/ni_mio_common.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index c66affd993aa..69d71f328006 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -4355,6 +4355,10 @@ static void ni_write_caldac(struct comedi_device *dev, int addr, int val) addr -= caldacs[type].n_chans; } + /* bits will be 0 if there is no caldac for the given addr */ + if (bits == 0) + return; + for (bit = 1 << (bits - 1); bit; bit >>= 1) { ni_writeb(dev, ((bit & bitstring) ? 0x02 : 0), Serial_Command); udelay(1); |
