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 09/10] pinctrl: mxs: Use devm_kcalloc() in two functions
Date: Fri, 14 Apr 2017 11:22:24 +0200	[thread overview]
Message-ID: <6b3abc7c-7fae-ce75-585c-8944153a9627@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 16:28:48 +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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/pinctrl/freescale/pinctrl-mxs.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/pinctrl/freescale/pinctrl-mxs.c b/drivers/pinctrl/freescale/pinctrl-mxs.c
index 41b5b07d5a2b..9e6dc0038c35 100644
--- a/drivers/pinctrl/freescale/pinctrl-mxs.c
+++ b/drivers/pinctrl/freescale/pinctrl-mxs.c
@@ -369,12 +369,12 @@ static int mxs_pinctrl_parse_group(struct platform_device *pdev,
 		return -EINVAL;
 	g->npins = length / sizeof(u32);
 
-	g->pins = devm_kzalloc(&pdev->dev, g->npins * sizeof(*g->pins),
+	g->pins = devm_kcalloc(&pdev->dev, g->npins, sizeof(*g->pins),
 			       GFP_KERNEL);
 	if (!g->pins)
 		return -ENOMEM;
 
-	g->muxsel = devm_kzalloc(&pdev->dev, g->npins * sizeof(*g->muxsel),
+	g->muxsel = devm_kcalloc(&pdev->dev, g->npins, sizeof(*g->muxsel),
 				 GFP_KERNEL);
 	if (!g->muxsel)
 		return -ENOMEM;
@@ -425,12 +425,12 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev,
 		}
 	}
 
-	soc->functions = devm_kzalloc(&pdev->dev, soc->nfunctions *
+	soc->functions = devm_kcalloc(&pdev->dev, soc->nfunctions,
 				      sizeof(*soc->functions), GFP_KERNEL);
 	if (!soc->functions)
 		return -ENOMEM;
 
-	soc->groups = devm_kzalloc(&pdev->dev, soc->ngroups *
+	soc->groups = devm_kcalloc(&pdev->dev, soc->ngroups,
 				   sizeof(*soc->groups), GFP_KERNEL);
 	if (!soc->groups)
 		return -ENOMEM;
@@ -491,7 +491,8 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev,
 
 		if (strcmp(fn, child->name)) {
 			f = &soc->functions[idxf++];
-			f->groups = devm_kzalloc(&pdev->dev, f->ngroups *
+			f->groups = devm_kcalloc(&pdev->dev,
+						 f->ngroups,
 						 sizeof(*f->groups),
 						 GFP_KERNEL);
 			if (!f->groups)
-- 
2.12.2


  parent reply	other threads:[~2017-04-14  9:22 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 ` [PATCH 02/10] pinctrl: imx: Use devm_kcalloc() in two functions SF Markus Elfring
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 ` SF Markus Elfring [this message]
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=6b3abc7c-7fae-ce75-585c-8944153a9627@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).