From: SF Markus Elfring <elfring@users.sourceforge.net>
To: "Andrew F. Davis" <afd@ti.com>,
Carlos Chinea <carlos.chinea@nokia.com>,
Linus Walleij <linus.walleij@linaro.org>,
Sebastian Reichel <sre@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 2/2] HSI: core: Use kcalloc() in two functions
Date: Tue, 25 Apr 2017 14:46:31 +0200 [thread overview]
Message-ID: <921ba1f4-132c-18b6-f5ff-99b9f3e562d9@users.sourceforge.net> (raw)
In-Reply-To: <52f7db50-a3a0-6bc5-a39f-1d235a5945cd@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 25 Apr 2017 14:17:50 +0200
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/hsi/hsi_core.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/hsi/hsi_core.c b/drivers/hsi/hsi_core.c
index c2a2a9795b0b..9065efd21851 100644
--- a/drivers/hsi/hsi_core.c
+++ b/drivers/hsi/hsi_core.c
@@ -267,14 +267,13 @@ static void hsi_add_client_from_dt(struct hsi_port *port,
cl->rx_cfg.num_channels = cells;
cl->tx_cfg.num_channels = cells;
-
- cl->rx_cfg.channels = kzalloc(cells * sizeof(channel), GFP_KERNEL);
+ cl->rx_cfg.channels = kcalloc(cells, sizeof(channel), GFP_KERNEL);
if (!cl->rx_cfg.channels) {
err = -ENOMEM;
goto err;
}
- cl->tx_cfg.channels = kzalloc(cells * sizeof(channel), GFP_KERNEL);
+ cl->tx_cfg.channels = kcalloc(cells, sizeof(channel), GFP_KERNEL);
if (!cl->tx_cfg.channels) {
err = -ENOMEM;
goto err2;
@@ -485,7 +484,7 @@ struct hsi_controller *hsi_alloc_controller(unsigned int n_ports, gfp_t flags)
hsi = kzalloc(sizeof(*hsi), flags);
if (!hsi)
return NULL;
- port = kzalloc(sizeof(*port)*n_ports, flags);
+ port = kcalloc(n_ports, sizeof(*port), flags);
if (!port) {
kfree(hsi);
return NULL;
--
2.12.2
next prev parent reply other threads:[~2017-04-25 12:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-25 12:43 [PATCH 0/2] HSI: Fine-tuning for three function implementations SF Markus Elfring
2017-04-25 12:45 ` [PATCH 1/2] HSI: Use kcalloc() in hsi_register_board_info() SF Markus Elfring
2017-04-25 12:46 ` SF Markus Elfring [this message]
2017-05-01 9:08 ` [PATCH 0/2] HSI: Fine-tuning for three function implementations Sebastian Reichel
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=921ba1f4-132c-18b6-f5ff-99b9f3e562d9@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=afd@ti.com \
--cc=carlos.chinea@nokia.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sre@kernel.org \
/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).