Staging: comedi: s626: Possible read buffer overflow fix
authorRoel Kluin <roel.kluin@gmail.com>
Fri, 7 Aug 2009 22:14:20 +0000 (00:14 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 15 Sep 2009 19:01:34 +0000 (12:01 -0700)
If `cmd->chanlist_len' is 0, then we write ppl[-1].

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/comedi/drivers/s626.c

index 6549d116f2e66b7c72994cc178b1cc40734775ed..80d2787d10637d0ab2bf53600d615ba5ff3206dc 100644 (file)
@@ -1707,7 +1707,8 @@ static int s626_ai_load_polllist(uint8_t * ppl, struct comedi_cmd *cmd)
                else
                        ppl[n] = (CR_CHAN((cmd->chanlist)[n])) | (RANGE_10V);
        }
-       ppl[n - 1] |= EOPL;
+       if (n != 0)
+               ppl[n - 1] |= EOPL;
 
        return n;
 }