From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-sh@vger.kernel.org, Rich Felker <dalias@libc.org>,
Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 1/3] sh/intc: Use kcalloc() in register_intc_controller()
Date: Fri, 13 Jan 2017 09:48:08 +0000 [thread overview]
Message-ID: <6f6f99f6-26f0-d002-ca85-d974d71aa518@users.sourceforge.net> (raw)
In-Reply-To: <4d37c4d8-d28b-bd98-968b-f544d6a213eb@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 13 Jan 2017 10:04:38 +0100
Multiplications for the size determination of memory allocations
indicated that array data structures should be processed.
Thus use the corresponding function "kcalloc".
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/sh/intc/core.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/sh/intc/core.c b/drivers/sh/intc/core.c
index 8e72bcbd3d6d..27817a8466f1 100644
--- a/drivers/sh/intc/core.c
+++ b/drivers/sh/intc/core.c
@@ -203,7 +203,8 @@ int __init register_intc_controller(struct intc_desc *desc)
if (desc->num_resources) {
d->nr_windows = desc->num_resources;
- d->window = kzalloc(d->nr_windows * sizeof(*d->window),
+ d->window = kcalloc(d->nr_windows,
+ sizeof(*d->window),
GFP_NOWAIT);
if (!d->window)
goto err1;
@@ -229,13 +230,12 @@ int __init register_intc_controller(struct intc_desc *desc)
d->nr_reg += hw->sense_regs ? hw->nr_sense_regs : 0;
d->nr_reg += hw->ack_regs ? hw->nr_ack_regs : 0;
d->nr_reg += hw->subgroups ? hw->nr_subgroups : 0;
-
- d->reg = kzalloc(d->nr_reg * sizeof(*d->reg), GFP_NOWAIT);
+ d->reg = kcalloc(d->nr_reg, sizeof(*d->reg), GFP_NOWAIT);
if (!d->reg)
goto err2;
#ifdef CONFIG_SMP
- d->smp = kzalloc(d->nr_reg * sizeof(*d->smp), GFP_NOWAIT);
+ d->smp = kcalloc(d->nr_reg, sizeof(*d->smp), GFP_NOWAIT);
if (!d->smp)
goto err3;
#endif
@@ -253,7 +253,8 @@ int __init register_intc_controller(struct intc_desc *desc)
}
if (hw->prio_regs) {
- d->prio = kzalloc(hw->nr_vectors * sizeof(*d->prio),
+ d->prio = kcalloc(hw->nr_vectors,
+ sizeof(*d->prio),
GFP_NOWAIT);
if (!d->prio)
goto err4;
@@ -269,7 +270,8 @@ int __init register_intc_controller(struct intc_desc *desc)
}
if (hw->sense_regs) {
- d->sense = kzalloc(hw->nr_vectors * sizeof(*d->sense),
+ d->sense = kcalloc(hw->nr_vectors,
+ sizeof(*d->sense),
GFP_NOWAIT);
if (!d->sense)
goto err5;
--
2.11.0
next prev parent reply other threads:[~2017-01-13 9:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-13 9:45 [PATCH 0/3] sh/intc: Fine-tuning for register_intc_controller() SF Markus Elfring
2017-01-13 9:48 ` SF Markus Elfring [this message]
2017-01-13 10:24 ` [PATCH 1/3] sh/intc: Use kcalloc() in register_intc_controller() Geert Uytterhoeven
2017-01-13 9:49 ` [PATCH 2/3] sh/intc: Combine substrings for a message " SF Markus Elfring
2017-01-13 9:50 ` [PATCH 3/3] sh/intc: Add a space character for better code readability " 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=6f6f99f6-26f0-d002-ca85-d974d71aa518@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=dalias@libc.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=ysato@users.sourceforge.jp \
/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).