diff options
author | Shraddha Barke <shraddha.6596@gmail.com> | 2015-10-09 15:33:27 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-10-13 03:35:21 (GMT) |
commit | be036bbe2c16929806ab747bfe8a88f5d6dbd0e5 (patch) | |
tree | 2f1d3f1d42c2ae25aab1ef84e53d5865fc5c9e0b /drivers/staging/rdma/ipath | |
parent | 314fcc0d53261a984788d09a1076c17a919504fe (diff) | |
download | linux-be036bbe2c16929806ab747bfe8a88f5d6dbd0e5.tar.xz |
Staging: rdma: ipath: Use kcalloc instead of kzalloc to allocate array
The advantage of kcalloc is, that will prevent integer overflows which
could result from the multiplication of number of elements and size and
it is also a bit nicer to read.
Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/rdma/ipath')
-rw-r--r-- | drivers/staging/rdma/ipath/ipath_init_chip.c | 2 | ||||
-rw-r--r-- | drivers/staging/rdma/ipath/ipath_qp.c | 2 | ||||
-rw-r--r-- | drivers/staging/rdma/ipath/ipath_verbs.c | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/drivers/staging/rdma/ipath/ipath_init_chip.c b/drivers/staging/rdma/ipath/ipath_init_chip.c index e95af81..cec1ebb 100644 --- a/drivers/staging/rdma/ipath/ipath_init_chip.c +++ b/drivers/staging/rdma/ipath/ipath_init_chip.c @@ -264,7 +264,7 @@ static int init_chip_first(struct ipath_devdata *dd) * Allocate full portcnt array, rather than just cfgports, because * cleanup iterates across all possible ports. */ - dd->ipath_pd = kzalloc(sizeof(*dd->ipath_pd) * dd->ipath_portcnt, + dd->ipath_pd = kcalloc(dd->ipath_portcnt, sizeof(*dd->ipath_pd), GFP_KERNEL); if (!dd->ipath_pd) { diff --git a/drivers/staging/rdma/ipath/ipath_qp.c b/drivers/staging/rdma/ipath/ipath_qp.c index face876..b2c6766 100644 --- a/drivers/staging/rdma/ipath/ipath_qp.c +++ b/drivers/staging/rdma/ipath/ipath_qp.c @@ -1027,7 +1027,7 @@ int ipath_init_qp_table(struct ipath_ibdev *idev, int size) idev->qp_table.last = 1; /* QPN 0 and 1 are special. */ idev->qp_table.max = size; idev->qp_table.nmaps = 1; - idev->qp_table.table = kzalloc(size * sizeof(*idev->qp_table.table), + idev->qp_table.table = kcalloc(size, sizeof(*idev->qp_table.table), GFP_KERNEL); if (idev->qp_table.table == NULL) { ret = -ENOMEM; diff --git a/drivers/staging/rdma/ipath/ipath_verbs.c b/drivers/staging/rdma/ipath/ipath_verbs.c index 17d9dca..40f7f05 100644 --- a/drivers/staging/rdma/ipath/ipath_verbs.c +++ b/drivers/staging/rdma/ipath/ipath_verbs.c @@ -2059,7 +2059,7 @@ int ipath_register_ib_device(struct ipath_devdata *dd) * the LKEY). The remaining bits act as a generation number or tag. */ idev->lk_table.max = 1 << ib_ipath_lkey_table_size; - idev->lk_table.table = kzalloc(idev->lk_table.max * + idev->lk_table.table = kcalloc(idev->lk_table.max, sizeof(*idev->lk_table.table), GFP_KERNEL); if (idev->lk_table.table == NULL) { |