Staging: iio: adc: Fix warning prefer kmalloc_array over kmalloc
authorDarshana Padmadas <darshanapadmadas@gmail.com>
Sat, 20 Sep 2014 13:00:19 +0000 (18:30 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 22 Sep 2014 14:58:47 +0000 (07:58 -0700)
This patch fixes the checkpatch warning:
WARNING: Prefer kmalloc_array over kmalloc with multiply

kmalloc_array is preffered for allocating for arrays.

Signed-off-by: Darshana Padmadas <darshanapadmadas@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/iio/adc/mxs-lradc.c

index 468327f..75fcb72 100644 (file)
@@ -1280,7 +1280,7 @@ static int mxs_lradc_buffer_preenable(struct iio_dev *iio)
        if (!ret)
                return -EBUSY;
 
-       lradc->buffer = kmalloc(len * sizeof(*lradc->buffer), GFP_KERNEL);
+       lradc->buffer = kmalloc_array(len, sizeof(*lradc->buffer), GFP_KERNEL);
        if (!lradc->buffer) {
                ret = -ENOMEM;
                goto err_mem;