diff options
author | Gustavo A. R. Silva <gustavoars@kernel.org> | 2021-09-28 17:11:57 -0500 |
---|---|---|
committer | Saeed Mahameed <saeedm@nvidia.com> | 2021-09-30 16:19:02 -0700 |
commit | ab9ace34158f48e65024e21994ed83d065e2ce6e (patch) | |
tree | 34991274a8a75c41edb4b943ce3896a793ed7d68 /drivers/net/ethernet/mellanox | |
parent | 806bf340e18017f1b30ec8ed3273a6a9523fbe82 (diff) | |
download | linux-ab9ace34158f48e65024e21994ed83d065e2ce6e.tar.gz |
net/mlx5: Use struct_size() helper in kvzalloc()
Make use of the struct_size() helper instead of an open-coded version,
in order to avoid any potential type mistakes or integer overflows that,
in the worse scenario, could lead to heap overflows.
Link: https://github.com/KSPP/linux/issues/160
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Diffstat (limited to 'drivers/net/ethernet/mellanox')
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c index 18e5aec14641..f542a36be62c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c @@ -497,8 +497,7 @@ static struct mlx5_fc_bulk *mlx5_fc_bulk_create(struct mlx5_core_dev *dev) alloc_bitmask = MLX5_CAP_GEN(dev, flow_counter_bulk_alloc); bulk_len = alloc_bitmask > 0 ? MLX5_FC_BULK_NUM_FCS(alloc_bitmask) : 1; - bulk = kvzalloc(sizeof(*bulk) + bulk_len * sizeof(struct mlx5_fc), - GFP_KERNEL); + bulk = kvzalloc(struct_size(bulk, fcs, bulk_len), GFP_KERNEL); if (!bulk) goto err_alloc_bulk; |