summaryrefslogtreecommitdiffstats
path: root/drivers/staging/iio/meter
diff options
context:
space:
mode:
authorThomas Meyer2011-11-29 22:08:00 +0100
committerGreg Kroah-Hartman2011-11-30 11:37:33 +0100
commitd83fb184945cd2daaafd33a702bba9cb7ed502bf (patch)
treeeb13dc818416eecbc1a31b564b76fe292021b40d /drivers/staging/iio/meter
parentstaging: vt6656: integer overflows in private_ioctl() (diff)
downloadkernel-qcow2-linux-d83fb184945cd2daaafd33a702bba9cb7ed502bf.tar.gz
kernel-qcow2-linux-d83fb184945cd2daaafd33a702bba9cb7ed502bf.tar.xz
kernel-qcow2-linux-d83fb184945cd2daaafd33a702bba9cb7ed502bf.zip
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/meter')
-rw-r--r--drivers/staging/iio/meter/ade7758_core.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c
index 348df974dfe9..9dc881f59bd8 100644
--- a/drivers/staging/iio/meter/ade7758_core.c
+++ b/drivers/staging/iio/meter/ade7758_core.c
@@ -746,12 +746,12 @@ static int __devinit ade7758_probe(struct spi_device *spi)
spi_set_drvdata(spi, indio_dev);
/* Allocate the comms buffers */
- st->rx = kzalloc(sizeof(*st->rx)*ADE7758_MAX_RX, GFP_KERNEL);
+ st->rx = kcalloc(ADE7758_MAX_RX, sizeof(*st->rx), GFP_KERNEL);
if (st->rx == NULL) {
ret = -ENOMEM;
goto error_free_dev;
}
- st->tx = kzalloc(sizeof(*st->tx)*ADE7758_MAX_TX, GFP_KERNEL);
+ st->tx = kcalloc(ADE7758_MAX_TX, sizeof(*st->tx), GFP_KERNEL);
if (st->tx == NULL) {
ret = -ENOMEM;
goto error_free_rx;