Skip to content

Commit

Permalink
net/mlx4_core: fix incorrect size allocation for dev->caps.spec_qps
Browse files Browse the repository at this point in the history
The current allocation for dev->caps.spec_qps is for the size of the
pointer and not the size of the actual  mlx4_spec_qps structure.  Fix
this by using the correct size.   Also splint allocation over a few
lines to make it cppcheck clean on overly wide lines.

Detected by CoverityScan, CID#1455222 ("Wrong sizeof argument")

Fixes: c73c8b1 ("net/mlx4_core: Dynamically allocate structs at mlx4_slave_cap")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Colin Ian King authored and David S. Miller committed Sep 3, 2017
1 parent 542deb8 commit 942e7e5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/net/ethernet/mellanox/mlx4/qp.c
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,9 @@ int mlx4_init_qp_table(struct mlx4_dev *dev)

/* In mfunc, calculate proxy and tunnel qp offsets for the PF here,
* since the PF does not call mlx4_slave_caps */
dev->caps.spec_qps = kcalloc(dev->caps.num_ports, sizeof(dev->caps.spec_qps), GFP_KERNEL);

dev->caps.spec_qps = kcalloc(dev->caps.num_ports,
sizeof(*dev->caps.spec_qps),
GFP_KERNEL);
if (!dev->caps.spec_qps) {
err = -ENOMEM;
goto err_mem;
Expand Down

0 comments on commit 942e7e5

Please sign in to comment.