Skip to content

Commit 8c8cf03

Browse files
ben-ishaySaeed Mahameed
authored andcommitted
net/mlx5e: SHAMPO, Fix constant expression result
mlx5e_build_shampo_hd_umr uses counters i and index incorrectly as unsigned, thus the err state err_unmap could stuck in endless loop. Change i to int to solve the first issue. Reduce index check to solve the second issue, the caller function validates that index could not rotate. Fixes: 64509b0 ("net/mlx5e: Add data path for SHAMPO feature") Signed-off-by: Ben Ben-Ishay <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 502e82b commit 8c8cf03

File tree

1 file changed

+3
-5
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+3
-5
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_rx.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -543,13 +543,13 @@ static int mlx5e_build_shampo_hd_umr(struct mlx5e_rq *rq,
543543
u16 klm_entries, u16 index)
544544
{
545545
struct mlx5e_shampo_hd *shampo = rq->mpwqe.shampo;
546-
u16 entries, pi, i, header_offset, err, wqe_bbs, new_entries;
546+
u16 entries, pi, header_offset, err, wqe_bbs, new_entries;
547547
u32 lkey = rq->mdev->mlx5e_res.hw_objs.mkey;
548548
struct page *page = shampo->last_page;
549549
u64 addr = shampo->last_addr;
550550
struct mlx5e_dma_info *dma_info;
551551
struct mlx5e_umr_wqe *umr_wqe;
552-
int headroom;
552+
int headroom, i;
553553

554554
headroom = rq->buff.headroom;
555555
new_entries = klm_entries - (shampo->pi & (MLX5_UMR_KLM_ALIGNMENT - 1));
@@ -601,9 +601,7 @@ static int mlx5e_build_shampo_hd_umr(struct mlx5e_rq *rq,
601601

602602
err_unmap:
603603
while (--i >= 0) {
604-
if (--index < 0)
605-
index = shampo->hd_per_wq - 1;
606-
dma_info = &shampo->info[index];
604+
dma_info = &shampo->info[--index];
607605
if (!(i & (MLX5E_SHAMPO_WQ_HEADER_PER_PAGE - 1))) {
608606
dma_info->addr = ALIGN_DOWN(dma_info->addr, PAGE_SIZE);
609607
mlx5e_page_release(rq, dma_info, true);

0 commit comments

Comments
 (0)