[PATCH 05/10] pinctrl: imx: Use devm_kmalloc_array() in imx_pinctrl_probe()

From: SF Markus Elfring
Date: Fri Apr 14 2017 - 05:16:24 EST


From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 13 Apr 2017 15:35:27 +0200

A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "devm_kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
drivers/pinctrl/freescale/pinctrl-imx.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c
index 44dbf6e38d79..078875361d76 100644
--- a/drivers/pinctrl/freescale/pinctrl-imx.c
+++ b/drivers/pinctrl/freescale/pinctrl-imx.c
@@ -726,8 +726,10 @@ int imx_pinctrl_probe(struct platform_device *pdev,
if (!ipctl)
return -ENOMEM;

- info->pin_regs = devm_kmalloc(&pdev->dev, sizeof(*info->pin_regs) *
- info->npins, GFP_KERNEL);
+ info->pin_regs = devm_kmalloc_array(&pdev->dev,
+ info->npins,
+ sizeof(*info->pin_regs),
+ GFP_KERNEL);
if (!info->pin_regs)
return -ENOMEM;

--
2.12.2