* [PATCH] net/mlx5: Use 2-factor allocator calls
@ 2018-07-04 17:28 Kees Cook
2018-07-07 11:15 ` David Miller
2018-07-09 23:00 ` David Miller
0 siblings, 2 replies; 5+ messages in thread
From: Kees Cook @ 2018-07-04 17:28 UTC (permalink / raw)
To: David S. Miller
Cc: Saeed Mahameed, Tariq Toukan, Leon Romanovsky, Vadim Pasternak,
netdev, linux-kernel
This restores the use of 2-factor allocation helpers that were already
fixed treewide. Please do not use open-coded multiplication; prefer,
instead, using 2-factor allocation helpers.
Signed-off-by: Kees Cook <keescook@chromium.org>
---
drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index bbd2fd0b2e06..c7791d036e9f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -349,7 +349,8 @@ static int mlx5e_rq_alloc_mpwqe_info(struct mlx5e_rq *rq,
{
int wq_sz = mlx5_wq_ll_get_size(&rq->mpwqe.wq);
- rq->mpwqe.info = kvzalloc_node(wq_sz * sizeof(*rq->mpwqe.info),
+ rq->mpwqe.info = kvzalloc_node(array_size(wq_sz,
+ sizeof(*rq->mpwqe.info)),
GFP_KERNEL, cpu_to_node(c->cpu));
if (!rq->mpwqe.info)
return -ENOMEM;
@@ -969,7 +970,7 @@ static int mlx5e_alloc_xdpsq_db(struct mlx5e_xdpsq *sq, int numa)
{
int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
- sq->db.di = kvzalloc_node(sizeof(*sq->db.di) * wq_sz,
+ sq->db.di = kvzalloc_node(array_size(wq_sz, sizeof(*sq->db.di)),
GFP_KERNEL, numa);
if (!sq->db.di) {
mlx5e_free_xdpsq_db(sq);
@@ -1028,7 +1029,8 @@ static int mlx5e_alloc_icosq_db(struct mlx5e_icosq *sq, int numa)
{
u8 wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
- sq->db.ico_wqe = kvzalloc_node(sizeof(*sq->db.ico_wqe) * wq_sz,
+ sq->db.ico_wqe = kvzalloc_node(array_size(wq_sz,
+ sizeof(*sq->db.ico_wqe)),
GFP_KERNEL, numa);
if (!sq->db.ico_wqe)
return -ENOMEM;
@@ -1083,9 +1085,11 @@ static int mlx5e_alloc_txqsq_db(struct mlx5e_txqsq *sq, int numa)
int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
int df_sz = wq_sz * MLX5_SEND_WQEBB_NUM_DS;
- sq->db.dma_fifo = kvzalloc_node(df_sz * sizeof(*sq->db.dma_fifo),
+ sq->db.dma_fifo = kvzalloc_node(array_size(df_sz,
+ sizeof(*sq->db.dma_fifo)),
GFP_KERNEL, numa);
- sq->db.wqe_info = kvzalloc_node(wq_sz * sizeof(*sq->db.wqe_info),
+ sq->db.wqe_info = kvzalloc_node(array_size(wq_sz,
+ sizeof(*sq->db.wqe_info)),
GFP_KERNEL, numa);
if (!sq->db.dma_fifo || !sq->db.wqe_info) {
mlx5e_free_txqsq_db(sq);
--
2.17.1
--
Kees Cook
Pixel Security
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] net/mlx5: Use 2-factor allocator calls
2018-07-04 17:28 [PATCH] net/mlx5: Use 2-factor allocator calls Kees Cook
@ 2018-07-07 11:15 ` David Miller
2018-07-08 8:06 ` Leon Romanovsky
2018-07-09 23:00 ` David Miller
1 sibling, 1 reply; 5+ messages in thread
From: David Miller @ 2018-07-07 11:15 UTC (permalink / raw)
To: keescook; +Cc: saeedm, tariqt, leon, vadimp, netdev, linux-kernel
From: Kees Cook <keescook@chromium.org>
Date: Wed, 4 Jul 2018 10:28:47 -0700
> This restores the use of 2-factor allocation helpers that were already
> fixed treewide. Please do not use open-coded multiplication; prefer,
> instead, using 2-factor allocation helpers.
>
> Signed-off-by: Kees Cook <keescook@chromium.org>
Saeed and co., please review.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net/mlx5: Use 2-factor allocator calls
2018-07-07 11:15 ` David Miller
@ 2018-07-08 8:06 ` Leon Romanovsky
2018-07-08 8:12 ` Tariq Toukan
0 siblings, 1 reply; 5+ messages in thread
From: Leon Romanovsky @ 2018-07-08 8:06 UTC (permalink / raw)
To: David Miller; +Cc: keescook, saeedm, tariqt, vadimp, netdev, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 492 bytes --]
On Sat, Jul 07, 2018 at 08:15:53PM +0900, David Miller wrote:
> From: Kees Cook <keescook@chromium.org>
> Date: Wed, 4 Jul 2018 10:28:47 -0700
>
> > This restores the use of 2-factor allocation helpers that were already
> > fixed treewide. Please do not use open-coded multiplication; prefer,
> > instead, using 2-factor allocation helpers.
> >
> > Signed-off-by: Kees Cook <keescook@chromium.org>
>
> Saeed and co., please review.
Thanks,
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net/mlx5: Use 2-factor allocator calls
2018-07-08 8:06 ` Leon Romanovsky
@ 2018-07-08 8:12 ` Tariq Toukan
0 siblings, 0 replies; 5+ messages in thread
From: Tariq Toukan @ 2018-07-08 8:12 UTC (permalink / raw)
To: David Miller
Cc: Leon Romanovsky, keescook, saeedm, vadimp, netdev, linux-kernel
On 08/07/2018 11:06 AM, Leon Romanovsky wrote:
> On Sat, Jul 07, 2018 at 08:15:53PM +0900, David Miller wrote:
>> From: Kees Cook <keescook@chromium.org>
>> Date: Wed, 4 Jul 2018 10:28:47 -0700
>>
>>> This restores the use of 2-factor allocation helpers that were already
>>> fixed treewide. Please do not use open-coded multiplication; prefer,
>>> instead, using 2-factor allocation helpers.
>>>
>>> Signed-off-by: Kees Cook <keescook@chromium.org>
>>
>> Saeed and co., please review.
>
> Thanks,
> Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
>
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net/mlx5: Use 2-factor allocator calls
2018-07-04 17:28 [PATCH] net/mlx5: Use 2-factor allocator calls Kees Cook
2018-07-07 11:15 ` David Miller
@ 2018-07-09 23:00 ` David Miller
1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2018-07-09 23:00 UTC (permalink / raw)
To: keescook; +Cc: saeedm, tariqt, leon, vadimp, netdev, linux-kernel
From: Kees Cook <keescook@chromium.org>
Date: Wed, 4 Jul 2018 10:28:47 -0700
> This restores the use of 2-factor allocation helpers that were already
> fixed treewide. Please do not use open-coded multiplication; prefer,
> instead, using 2-factor allocation helpers.
>
> Signed-off-by: Kees Cook <keescook@chromium.org>
Applied to net-next, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-07-09 23:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-04 17:28 [PATCH] net/mlx5: Use 2-factor allocator calls Kees Cook
2018-07-07 11:15 ` David Miller
2018-07-08 8:06 ` Leon Romanovsky
2018-07-08 8:12 ` Tariq Toukan
2018-07-09 23:00 ` David Miller
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).