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>
                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);