Commit d4bf105b authored by Alexandre Belloni's avatar Alexandre Belloni Committed by Jonathan Cameron

iio: mxs-lradc: fix buffer overflow

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: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 71bd8945
...@@ -1613,7 +1613,7 @@ static int mxs_lradc_probe(struct platform_device *pdev) ...@@ -1613,7 +1613,7 @@ static int mxs_lradc_probe(struct platform_device *pdev)
* of the array. * of the array.
*/ */
scale_uv = ((u64)lradc->vref_mv[i] * 100000000) >> scale_uv = ((u64)lradc->vref_mv[i] * 100000000) >>
(iio->channels[i].scan_type.realbits - s); (LRADC_RESOLUTION - s);
lradc->scale_avail[i][s].nano = lradc->scale_avail[i][s].nano =
do_div(scale_uv, 100000000) * 10; do_div(scale_uv, 100000000) * 10;
lradc->scale_avail[i][s].integer = scale_uv; lradc->scale_avail[i][s].integer = scale_uv;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment