diff options
author | Thomas Meyer <thomas@m3y3r.de> | 2011-11-29 16:08:00 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-11-30 05:37:33 -0500 |
commit | d83fb184945cd2daaafd33a702bba9cb7ed502bf (patch) | |
tree | eb13dc818416eecbc1a31b564b76fe292021b40d /drivers/staging/iio/accel/lis3l02dq_ring.c | |
parent | 201320435d017e8ebd449034547ef0518ec4d056 (diff) |
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/accel/lis3l02dq_ring.c')
-rw-r--r-- | drivers/staging/iio/accel/lis3l02dq_ring.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c index 89527af8f4c..a9005027120 100644 --- a/drivers/staging/iio/accel/lis3l02dq_ring.c +++ b/drivers/staging/iio/accel/lis3l02dq_ring.c | |||
@@ -93,8 +93,7 @@ static int lis3l02dq_read_all(struct iio_dev *indio_dev, u8 *rx_array) | |||
93 | struct spi_message msg; | 93 | struct spi_message msg; |
94 | int ret, i, j = 0; | 94 | int ret, i, j = 0; |
95 | 95 | ||
96 | xfers = kzalloc((buffer->scan_count) * 2 | 96 | xfers = kcalloc((buffer->scan_count) * 2, sizeof(*xfers), GFP_KERNEL); |
97 | * sizeof(*xfers), GFP_KERNEL); | ||
98 | if (!xfers) | 97 | if (!xfers) |
99 | return -ENOMEM; | 98 | return -ENOMEM; |
100 | 99 | ||