iio: Use kmalloc_array() in iio_scan_mask_set()
commit 057ac1acdfc4743f066fcefe359385cad00549eb upstream. A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "kmalloc_array". This issue was detected by using the Coccinelle software. Change-Id: I56a1fb8b1124230dcc53d0100fe2eef31952a789 Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
This commit is contained in:
parent
b0c3365842
commit
8fb10e5eef
|
@ -719,10 +719,9 @@ int iio_scan_mask_set(struct iio_dev *indio_dev,
|
|||
const unsigned long *mask;
|
||||
unsigned long *trialmask;
|
||||
|
||||
trialmask = kmalloc(sizeof(*trialmask)*
|
||||
BITS_TO_LONGS(indio_dev->masklength),
|
||||
GFP_KERNEL);
|
||||
|
||||
trialmask = kmalloc_array(BITS_TO_LONGS(indio_dev->masklength),
|
||||
sizeof(*trialmask),
|
||||
GFP_KERNEL);
|
||||
if (trialmask == NULL)
|
||||
return -ENOMEM;
|
||||
if (!indio_dev->masklength) {
|
||||
|
|
Loading…
Reference in New Issue