From: Michael Hennerich Date: Wed, 6 Oct 2010 14:15:37 +0000 (+0200) Subject: staging: iio: adc: max1363: prevent buffer overflow X-Git-Tag: v2.6.37-rc1~60^2~3^2~310 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e1517c00da6d35911b6451f886d55e22d56393ad;p=profile%2Fivi%2Fkernel-x86-ivi.git 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 --- diff --git a/drivers/staging/iio/adc/max1363_ring.c b/drivers/staging/iio/adc/max1363_ring.c index 1d6ce54..896a367 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;