linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-gpio@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	Gary Bisson <gary.bisson@boundarydevices.com>,
	Laxman Dewangan <ldewangan@nvidia.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Paul Gortmaker <paul.gortmaker@windriver.com>,
	Peng Fan <van.freenix@gmail.com>, Shawn Guo <shawnguo@kernel.org>,
	Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 02/10] pinctrl: imx: Use devm_kcalloc() in two functions
Date: Fri, 14 Apr 2017 11:07:53 +0200	[thread overview]
Message-ID: <4c55e8b6-a904-408f-58c4-18f3053bb633@users.sourceforge.net> (raw)
In-Reply-To: <59fae4ac-9e07-232a-4843-92dd9e0cf2ef@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
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 <elfring@users.sourceforge.net>
---
 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


  parent reply	other threads:[~2017-04-14  9:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-14  9:00 [PATCH 00/10] pinctrl: freescale: Fine-tuning for ten function implementations SF Markus Elfring
2017-04-14  9:03 ` [PATCH 1/10] pinctrl: imx: Use kmalloc_array() in imx_dt_node_to_map() SF Markus Elfring
2017-04-14  9:07 ` SF Markus Elfring [this message]
2017-04-14  9:11 ` [PATCH 03/10] pinctrl: imx: Return directly after a failed devm_kcalloc() in imx_pinctrl_parse_functions() SF Markus Elfring
2017-04-14  9:14 ` [PATCH 04/10] pinctrl: imx: Improve another size determination " SF Markus Elfring
2017-04-14  9:15 ` [PATCH 05/10] pinctrl: imx: Use devm_kmalloc_array() in imx_pinctrl_probe() SF Markus Elfring
2017-04-14  9:17 ` [PATCH 06/10] pinctrl: imx: Use seq_putc() in imx_pinconf_group_dbg_show() SF Markus Elfring
2017-04-14  9:19 ` [PATCH 07/10] pinctrl: imx: Use seq_puts() in imx_pinconf_dbg_show() SF Markus Elfring
2017-04-14  9:20 ` [PATCH 08/10] pinctrl: imx1-core: Use kmalloc_array() in imx_dt_node_to_map() SF Markus Elfring
2017-04-14  9:22 ` [PATCH 09/10] pinctrl: mxs: Use devm_kcalloc() in two functions SF Markus Elfring
2017-04-14  9:23 ` [PATCH 10/10] pinctrl: mxs: Use kcalloc() in mxs_dt_node_to_map() SF Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4c55e8b6-a904-408f-58c4-18f3053bb633@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=arnd@arndb.de \
    --cc=gary.bisson@boundarydevices.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=ldewangan@nvidia.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul.gortmaker@windriver.com \
    --cc=shawnguo@kernel.org \
    --cc=van.freenix@gmail.com \
    --cc=vladimir_zapolskiy@mentor.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).