summaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/hfi1/init.c
diff options
context:
space:
mode:
authorKamenee Arumugam <kamenee.arumugam@intel.com>2018-02-01 12:37:30 -0800
committerJason Gunthorpe <jgg@mellanox.com>2018-02-01 15:43:32 -0700
commit953a9cebeab43f33baed79d1a9ef643bfb249c4b (patch)
tree139004705604d5121675065b3ec0ebd26ce5b9a3 /drivers/infiniband/hw/hfi1/init.c
parent2ff124d597c2df8696169ce0006fc974c49a4569 (diff)
downloadlinux-953a9cebeab43f33baed79d1a9ef643bfb249c4b.tar.gz
linux-953a9cebeab43f33baed79d1a9ef643bfb249c4b.tar.bz2
linux-953a9cebeab43f33baed79d1a9ef643bfb249c4b.zip
IB/hfi1: Convert kzalloc_node and kcalloc to use kcalloc_node
Kzalloc_node API doesn't check for overflows in size multiplication. While kcalloc API check for overflows in size multiplication but these implementations are not NUMA-aware. This conversion allowed for correcting an allocation used in the hot path to be on the local NUMA and ensure us overflow free multiplication for the size of a memory allocation. Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com> Signed-off-by: Kamenee Arumugam <kamenee.arumugam@intel.com> Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers/infiniband/hw/hfi1/init.c')
-rw-r--r--drivers/infiniband/hw/hfi1/init.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/infiniband/hw/hfi1/init.c b/drivers/infiniband/hw/hfi1/init.c
index 8c4f04032b28..33eba2356742 100644
--- a/drivers/infiniband/hw/hfi1/init.c
+++ b/drivers/infiniband/hw/hfi1/init.c
@@ -172,7 +172,7 @@ int hfi1_create_kctxts(struct hfi1_devdata *dd)
u16 i;
int ret;
- dd->rcd = kzalloc_node(dd->num_rcv_contexts * sizeof(*dd->rcd),
+ dd->rcd = kcalloc_node(dd->num_rcv_contexts, sizeof(*dd->rcd),
GFP_KERNEL, dd->node);
if (!dd->rcd)
return -ENOMEM;
@@ -439,15 +439,16 @@ int hfi1_create_ctxtdata(struct hfi1_pportdata *ppd, int numa,
* The resulting value will be rounded down to the closest
* multiple of dd->rcv_entries.group_size.
*/
- rcd->egrbufs.buffers = kzalloc_node(
- rcd->egrbufs.count * sizeof(*rcd->egrbufs.buffers),
- GFP_KERNEL, numa);
+ rcd->egrbufs.buffers =
+ kcalloc_node(rcd->egrbufs.count,
+ sizeof(*rcd->egrbufs.buffers),
+ GFP_KERNEL, numa);
if (!rcd->egrbufs.buffers)
goto bail;
- rcd->egrbufs.rcvtids = kzalloc_node(
- rcd->egrbufs.count *
- sizeof(*rcd->egrbufs.rcvtids),
- GFP_KERNEL, numa);
+ rcd->egrbufs.rcvtids =
+ kcalloc_node(rcd->egrbufs.count,
+ sizeof(*rcd->egrbufs.rcvtids),
+ GFP_KERNEL, numa);
if (!rcd->egrbufs.rcvtids)
goto bail;
rcd->egrbufs.size = eager_buffer_size;