From e1517c00da6d35911b6451f886d55e22d56393ad Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Wed, 6 Oct 2010 16:15:37 +0200 Subject: [PATCH] staging: iio: adc: max1363: prevent buffer overflow ring->access.read_last() reads the entire datum from the ring including padding and time stamp. Acked-by: Jonathan Cameron Signed-off-by: Michael Hennerich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/max1363_ring.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/iio/adc/max1363_ring.c b/drivers/staging/iio/adc/max1363_ring.c index 1d6ce54e9a86..896a3672b332 100644 --- a/drivers/staging/iio/adc/max1363_ring.c +++ b/drivers/staging/iio/adc/max1363_ring.c @@ -38,9 +38,8 @@ int max1363_single_channel_from_ring(long mask, struct max1363_state *st) ret = -EBUSY; goto error_ret; } - numvals = hweight_long(st->current_mode->modemask); - ring_data = kmalloc(numvals*2, GFP_KERNEL); + ring_data = kmalloc(ring->access.get_bytes_per_datum(ring), GFP_KERNEL); if (ring_data == NULL) { ret = -ENOMEM; goto error_ret; -- 2.39.5