summaryrefslogtreecommitdiff
path: root/drivers/staging/iio/adc/ad7280a.c
diff options
context:
space:
mode:
authorThomas Meyer <thomas@m3y3r.de>2011-11-29 21:08:00 (GMT)
committerGreg Kroah-Hartman <gregkh@suse.de>2011-11-30 10:37:33 (GMT)
commitd83fb184945cd2daaafd33a702bba9cb7ed502bf (patch)
treeeb13dc818416eecbc1a31b564b76fe292021b40d /drivers/staging/iio/adc/ad7280a.c
parent201320435d017e8ebd449034547ef0518ec4d056 (diff)
downloadlinux-fsl-qoriq-d83fb184945cd2daaafd33a702bba9cb7ed502bf.tar.xz
staging: iio: Use kcalloc instead of kzalloc to allocate array
The advantage of kcalloc is, that will prevent integer overflows which could result from the multiplication of number of elements and size and it is also a bit nicer to read. The semantic patch that makes this change is available in https://lkml.org/lkml/2011/11/25/107 Signed-off-by: Thomas Meyer <thomas@m3y3r.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/iio/adc/ad7280a.c')
-rw-r--r--drivers/staging/iio/adc/ad7280a.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
index 1af4194..f70bff2 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -488,8 +488,8 @@ static int ad7280_channel_init(struct ad7280_state *st)
{
int dev, ch, cnt;
- st->channels = kzalloc(sizeof(*st->channels) *
- ((st->slave_num + 1) * 12 + 2), GFP_KERNEL);
+ st->channels = kcalloc((st->slave_num + 1) * 12 + 2,
+ sizeof(*st->channels), GFP_KERNEL);
if (st->channels == NULL)
return -ENOMEM;
@@ -683,7 +683,7 @@ static irqreturn_t ad7280_event_handler(int irq, void *private)
unsigned *channels;
int i, ret;
- channels = kzalloc(sizeof(*channels) * st->scan_cnt, GFP_KERNEL);
+ channels = kcalloc(st->scan_cnt, sizeof(*channels), GFP_KERNEL);
if (channels == NULL)
return IRQ_HANDLED;