Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1616953
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 2/5] IB/qib: Use kmalloc_array() in qib_init_7322_variables() |
| Date | 2017-04-05 16:00 +0200 |
| Message-ID | <tsTDA-3ln-11@gated-at.bofh.it> (permalink) |
| References | <tsTDz-3ln-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Apr 2017 09:51:33 +0200
Multiplications for the size determination of memory allocations
indicated that array data structures should be processed.
Thus use the corresponding function "kmalloc_array".
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/infiniband/hw/qib/qib_iba7322.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c b/drivers/infiniband/hw/qib/qib_iba7322.c
index e4e4e675c89c..490f432809b8 100644
--- a/drivers/infiniband/hw/qib/qib_iba7322.c
+++ b/drivers/infiniband/hw/qib/qib_iba7322.c
@@ -6442,12 +6442,15 @@ static int qib_init_7322_variables(struct qib_devdata *dd)
sbufcnt = dd->piobcnt2k + dd->piobcnt4k +
NUM_VL15_BUFS + BITS_PER_LONG - 1;
sbufcnt /= BITS_PER_LONG;
- dd->cspec->sendchkenable = kmalloc(sbufcnt *
- sizeof(*dd->cspec->sendchkenable), GFP_KERNEL);
- dd->cspec->sendgrhchk = kmalloc(sbufcnt *
- sizeof(*dd->cspec->sendgrhchk), GFP_KERNEL);
- dd->cspec->sendibchk = kmalloc(sbufcnt *
- sizeof(*dd->cspec->sendibchk), GFP_KERNEL);
+ dd->cspec->sendchkenable = kmalloc_array(sbufcnt,
+ sizeof(*dd->cspec->sendchkenable),
+ GFP_KERNEL);
+ dd->cspec->sendgrhchk = kmalloc_array(sbufcnt,
+ sizeof(*dd->cspec->sendgrhchk),
+ GFP_KERNEL);
+ dd->cspec->sendibchk = kmalloc_array(sbufcnt,
+ sizeof(*dd->cspec->sendibchk),
+ GFP_KERNEL);
if (!dd->cspec->sendchkenable || !dd->cspec->sendgrhchk ||
!dd->cspec->sendibchk) {
ret = -ENOMEM;
--
2.12.2
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/5] IB/qib: Fine-tuning for four function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-05 16:00 +0200
[PATCH 2/5] IB/qib: Use kmalloc_array() in qib_init_7322_variables() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-05 16:00 +0200
Re: [PATCH 2/5] IB/qib: Use kmalloc_array() in qib_init_7322_variables() Yuval Shaia <yuval.shaia@oracle.com> - 2017-04-05 16:30 +0200
[PATCH 1/5] IB/qib: Use kcalloc() in qib_init_iba7322_funcs() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-05 16:00 +0200
Re: [PATCH 1/5] IB/qib: Use kcalloc() in qib_init_iba7322_funcs() Yuval Shaia <yuval.shaia@oracle.com> - 2017-04-05 16:40 +0200
Re: [PATCH 1/5] IB/qib: Use kcalloc() in qib_init_iba7322_funcs() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-05 17:00 +0200
Re: [PATCH 1/5] IB/qib: Use kcalloc() in qib_init_iba7322_funcs() Johannes Thumshirn <jthumshirn@suse.de> - 2017-04-05 17:10 +0200
Re: [PATCH 1/5] IB/qib: Use kcalloc() in qib_init_iba7322_funcs() Yuval Shaia <yuval.shaia@oracle.com> - 2017-04-05 17:20 +0200
[PATCH 3/5] IB/qib: Use kcalloc() in qib_alloc_devdata() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-05 16:00 +0200
[PATCH 4/5] IB/qib: Use kcalloc() in qib_init_pportdata() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-05 16:00 +0200
[PATCH 5/5] IB/qib: Adjust two size determinations in qib_init_pportdata() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-05 16:10 +0200
Re: [PATCH 5/5] IB/qib: Adjust two size determinations in qib_init_pportdata() Yuval Shaia <yuval.shaia@oracle.com> - 2017-04-05 16:40 +0200
Re: [PATCH 5/5] IB/qib: Adjust two size determinations in qib_init_pportdata() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-05 17:10 +0200
Re: [PATCH 5/5] IB/qib: Adjust two size determinations in qib_init_pportdata() Yuval Shaia <yuval.shaia@oracle.com> - 2017-04-05 17:20 +0200
Re: IB/qib: Adjust two size determinations in qib_init_pportdata() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-05 17:30 +0200
Re: IB/qib: Adjust two size determinations in qib_init_pportdata() Yuval Shaia <yuval.shaia@oracle.com> - 2017-04-06 21:50 +0200
Re: IB/qib: Adjust two size determinations in qib_init_pportdata() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-06 22:40 +0200
Re: [PATCH 5/5] IB/qib: Adjust two size determinations in qib_init_pportdata() Bart Van Assche <Bart.VanAssche@sandisk.com> - 2017-04-05 17:20 +0200
Re: [PATCH 0/5] IB/qib: Fine-tuning for four function implementations Dennis Dalessandro <dennis.dalessandro@intel.com> - 2017-04-06 02:40 +0200
csiph-web