From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-rdma@vger.kernel.org, Doug Ledford <dledford@redhat.com>,
Faisal Latif <faisal.latif@intel.com>,
Hal Rosenstock <hal.rosenstock@gmail.com>,
Sean Hefty <sean.hefty@intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 2/5] IB/nes: Use kcalloc() in nes_reg_user_mr()
Date: Mon, 6 Mar 2017 18:41:40 +0100 [thread overview]
Message-ID: <192fcb99-eef6-8820-9260-b6ad0ee60165@users.sourceforge.net> (raw)
In-Reply-To: <502a5a6f-ee91-dd2f-cdc7-63f396059529@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 6 Mar 2017 16:26:25 +0100
A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus reuse the corresponding function "kcalloc".
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/infiniband/hw/nes/nes_verbs.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
index d3eae2f3e9f5..a28dfeaa1f45 100644
--- a/drivers/infiniband/hw/nes/nes_verbs.c
+++ b/drivers/infiniband/hw/nes/nes_verbs.c
@@ -2260,8 +2260,9 @@ static struct ib_mr *nes_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
ibmr = ERR_PTR(-ENOMEM);
goto reg_user_mr_err;
}
- root_vpbl.leaf_vpbl = kzalloc(sizeof(*root_vpbl.leaf_vpbl)*1024,
- GFP_KERNEL);
+ root_vpbl.leaf_vpbl = kcalloc(1024,
+ sizeof(*root_vpbl.leaf_vpbl),
+ GFP_KERNEL);
if (!root_vpbl.leaf_vpbl) {
ib_umem_release(region);
pci_free_consistent(nesdev->pcidev, 8192, root_vpbl.pbl_vbase,
--
2.12.0
next prev parent reply other threads:[~2017-03-06 17:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-06 17:38 [PATCH 0/5] IB/nes: Fine-tuning for some function implementations SF Markus Elfring
2017-03-06 17:40 ` [PATCH 1/5] IB/nes: Use kcalloc() in nes_init_mgt_qp() SF Markus Elfring
2017-03-06 17:41 ` SF Markus Elfring [this message]
2017-03-06 17:42 ` [PATCH 3/5] IB/nes: Adjust 16 checks for null pointers SF Markus Elfring
2017-03-06 17:43 ` [PATCH 4/5] IB/nes: Delete unnecessary braces SF Markus Elfring
2017-03-06 18:37 ` Joe Perches
[not found] ` <1488825451.2210.14.camel-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
2017-03-07 0:34 ` [PATCH] IB/nes: Neaten nes_alloc_mw Joe Perches
2017-03-06 20:56 ` [PATCH 4/5] IB/nes: Delete unnecessary braces Julia Lawall
2017-03-06 17:44 ` [PATCH 5/5] IB/nes: Improve size determinations in two functions 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=192fcb99-eef6-8820-9260-b6ad0ee60165@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=dledford@redhat.com \
--cc=faisal.latif@intel.com \
--cc=hal.rosenstock@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=sean.hefty@intel.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