* [PATCH][net-next] net/mlx5e: Use array_size() helper
@ 2021-09-28 21:54 Gustavo A. R. Silva
2021-09-30 19:06 ` Saeed Mahameed
0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2021-09-28 21:54 UTC (permalink / raw)
To: Saeed Mahameed, Leon Romanovsky, David S. Miller, Jakub Kicinski
Cc: netdev, linux-rdma, linux-kernel, Gustavo A. R. Silva, linux-hardening
Use array_size() helper to aid in 2-factor allocation instances.
Link: https://github.com/KSPP/linux/issues/160
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 3fd515e7bf30..3ab5929ff131 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -930,9 +930,10 @@ static int mlx5e_alloc_xdpsq_fifo(struct mlx5e_xdpsq *sq, int numa)
struct mlx5e_xdp_info_fifo *xdpi_fifo = &sq->db.xdpi_fifo;
int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
int dsegs_per_wq = wq_sz * MLX5_SEND_WQEBB_NUM_DS;
+ size_t size;
- xdpi_fifo->xi = kvzalloc_node(sizeof(*xdpi_fifo->xi) * dsegs_per_wq,
- GFP_KERNEL, numa);
+ size = array_size(sizeof(*xdpi_fifo->xi), dsegs_per_wq);
+ xdpi_fifo->xi = kvzalloc_node(size, GFP_KERNEL, numa);
if (!xdpi_fifo->xi)
return -ENOMEM;
@@ -946,10 +947,11 @@ static int mlx5e_alloc_xdpsq_fifo(struct mlx5e_xdpsq *sq, int numa)
static int mlx5e_alloc_xdpsq_db(struct mlx5e_xdpsq *sq, int numa)
{
int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
+ size_t size;
int err;
- sq->db.wqe_info = kvzalloc_node(sizeof(*sq->db.wqe_info) * wq_sz,
- GFP_KERNEL, numa);
+ size = array_size(sizeof(*sq->db.wqe_info), wq_sz);
+ sq->db.wqe_info = kvzalloc_node(size, GFP_KERNEL, numa);
if (!sq->db.wqe_info)
return -ENOMEM;
--
2.27.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH][net-next] net/mlx5e: Use array_size() helper
2021-09-28 21:54 [PATCH][net-next] net/mlx5e: Use array_size() helper Gustavo A. R. Silva
@ 2021-09-30 19:06 ` Saeed Mahameed
0 siblings, 0 replies; 2+ messages in thread
From: Saeed Mahameed @ 2021-09-30 19:06 UTC (permalink / raw)
To: davem, kuba, gustavoars, leon
Cc: linux-hardening, netdev, linux-rdma, linux-kernel
On Tue, 2021-09-28 at 16:54 -0500, Gustavo A. R. Silva wrote:
> Use array_size() helper to aid in 2-factor allocation instances.
>
> Link: https://github.com/KSPP/linux/issues/160
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
>
applied to net-next-mlx5
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-09-30 19:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-28 21:54 [PATCH][net-next] net/mlx5e: Use array_size() helper Gustavo A. R. Silva
2021-09-30 19:06 ` Saeed Mahameed
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).