staging: comedi: dt282x: prevent "empty acquisition" async commands
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Tue, 9 Sep 2014 23:15:48 +0000 (16:15 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 Sep 2014 21:35:20 +0000 (14:35 -0700)
This driver currently allows a cmd->stop_src == TRIG_COUNT with a cmd->stop_arg
of 0 for both the analog input and output async commands. The (*do_cmd) for
both subdevices sets up and starts the command without handling the "empty
acquisition". This results in the interrupt functions trying to transfer 0 data
samples.

Validate that the cmd->stop_arg is >= 1 in the (*do_cmdtest) to prevent the
"empty acquisition".

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>
drivers/staging/comedi/drivers/dt282x.c

index e725e3b..cc974a5 100644 (file)
@@ -728,11 +728,10 @@ static int dt282x_ai_cmdtest(struct comedi_device *dev,
        err |= cfc_check_trigger_arg_min(&cmd->convert_arg, board->ai_speed);
        err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
 
-       if (cmd->stop_src == TRIG_COUNT) {
-               /* any count is allowed */
-       } else {        /* TRIG_NONE */
+       if (cmd->stop_src == TRIG_COUNT)
+               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+       else    /* TRIG_EXT | TRIG_NONE */
                err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
-       }
 
        if (err)
                return 3;
@@ -890,11 +889,10 @@ static int dt282x_ao_cmdtest(struct comedi_device *dev,
        err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
        err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
 
-       if (cmd->stop_src == TRIG_COUNT) {
-               /* any count is allowed */
-       } else {        /* TRIG_NONE */
+       if (cmd->stop_src == TRIG_COUNT)
+               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+       else    /* TRIG_EXT | TRIG_NONE */
                err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
-       }
 
        if (err)
                return 3;