From: Markus Elfring <[email protected]>
Date: Thu, 13 Apr 2017 14:13:00 +0200

* Multiplications for the size determination of memory allocations
  indicated that array data structures should be processed.
  Thus use the corresponding function "devm_kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of data types by pointer dereferences
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <[email protected]>
---
 drivers/pinctrl/freescale/pinctrl-imx.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c 
b/drivers/pinctrl/freescale/pinctrl-imx.c
index 563d24e7989d..975ed40cb774 100644
--- a/drivers/pinctrl/freescale/pinctrl-imx.c
+++ b/drivers/pinctrl/freescale/pinctrl-imx.c
@@ -509,10 +509,10 @@ static int imx_pinctrl_parse_groups(struct device_node 
*np,
        }
 
        grp->num_pins = size / pin_size;
-       grp->data = devm_kzalloc(info->dev, grp->num_pins *
+       grp->data = devm_kcalloc(info->dev, grp->num_pins,
                                 sizeof(struct imx_pin), GFP_KERNEL);
-       grp->pins = devm_kzalloc(info->dev, grp->num_pins *
-                                sizeof(unsigned int), GFP_KERNEL);
+       grp->pins = devm_kcalloc(info->dev, grp->num_pins,
+                                sizeof(*grp->pins), GFP_KERNEL);
        if (!grp->pins || !grp->data)
                return -ENOMEM;
 
@@ -581,9 +581,10 @@ static int imx_pinctrl_parse_functions(struct device_node 
*np,
                dev_err(info->dev, "no groups defined in %s\n", np->full_name);
                return -EINVAL;
        }
-       func->group_names = devm_kzalloc(info->dev,
-                                        func->num_group_names *
-                                        sizeof(char *), GFP_KERNEL);
+       func->group_names = devm_kcalloc(info->dev,
+                                        func->num_group_names,
+                                        sizeof(*func->group_names),
+                                        GFP_KERNEL);
 
        for_each_child_of_node(np, child) {
                func->group_names[i] = child->name;
-- 
2.12.2

Reply via email to