iio: mxs-lradc: fix buffer overflow
authorAlexandre Belloni <alexandre.belloni@free-electrons.com>
Mon, 13 Jan 2014 16:02:00 +0000 (16:02 +0000)
committerJonathan Cameron <jic23@kernel.org>
Sat, 8 Feb 2014 10:06:30 +0000 (10:06 +0000)
Fixes:
drivers/staging/iio/adc/mxs-lradc.c:1556 mxs_lradc_probe() error: buffer
overflow 'iio->channels' 15 <= 15

The reported available scales for in_voltage15 were also wrong.

The realbits lookup is not necessary as all the channels of the LRADC have the
same resolution, use LRADC_RESOLUTION instead.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/staging/iio/adc/mxs-lradc.c

index df71669bb60ea51be793903d7a62df399e388c55..aa86849daebaffd864734369daac0eae9b61f0bf 100644 (file)
@@ -1613,7 +1613,7 @@ static int mxs_lradc_probe(struct platform_device *pdev)
                         * of the array.
                         */
                        scale_uv = ((u64)lradc->vref_mv[i] * 100000000) >>
-                                  (iio->channels[i].scan_type.realbits - s);
+                                  (LRADC_RESOLUTION - s);
                        lradc->scale_avail[i][s].nano =
                                        do_div(scale_uv, 100000000) * 10;
                        lradc->scale_avail[i][s].integer = scale_uv;