From: Saeed Mahameed <saeed@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, Ben Ben-Ishay <benishay@nvidia.com>,
Tariq Toukan <tariqt@nvidia.com>,
Saeed Mahameed <saeedm@nvidia.com>
Subject: [net 13/13] net/mlx5e: SHAMPO, Fix constant expression result
Date: Tue, 30 Nov 2021 22:37:09 -0800 [thread overview]
Message-ID: <20211201063709.229103-14-saeed@kernel.org> (raw)
In-Reply-To: <20211201063709.229103-1-saeed@kernel.org>
From: Ben Ben-Ishay <benishay@nvidia.com>
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: 64509b052525 ("net/mlx5e: Add data path for SHAMPO feature")
Signed-off-by: Ben Ben-Ishay <benishay@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index 96967b0a2441..793511d5ee4c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -543,13 +543,13 @@ static int mlx5e_build_shampo_hd_umr(struct mlx5e_rq *rq,
u16 klm_entries, u16 index)
{
struct mlx5e_shampo_hd *shampo = rq->mpwqe.shampo;
- u16 entries, pi, i, header_offset, err, wqe_bbs, new_entries;
+ u16 entries, pi, header_offset, err, wqe_bbs, new_entries;
u32 lkey = rq->mdev->mlx5e_res.hw_objs.mkey;
struct page *page = shampo->last_page;
u64 addr = shampo->last_addr;
struct mlx5e_dma_info *dma_info;
struct mlx5e_umr_wqe *umr_wqe;
- int headroom;
+ int headroom, i;
headroom = rq->buff.headroom;
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,
err_unmap:
while (--i >= 0) {
- if (--index < 0)
- index = shampo->hd_per_wq - 1;
- dma_info = &shampo->info[index];
+ dma_info = &shampo->info[--index];
if (!(i & (MLX5E_SHAMPO_WQ_HEADER_PER_PAGE - 1))) {
dma_info->addr = ALIGN_DOWN(dma_info->addr, PAGE_SIZE);
mlx5e_page_release(rq, dma_info, true);
--
2.31.1
prev parent reply other threads:[~2021-12-01 6:37 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-01 6:36 [pull request][net 00/13] mlx5 fixes 2021-11-30 Saeed Mahameed
2021-12-01 6:36 ` [net 01/13] net/mlx5e: IPsec: Fix Software parser inner l3 type setting in case of encapsulation Saeed Mahameed
2021-12-01 15:00 ` patchwork-bot+netdevbpf
2021-12-01 6:36 ` [net 02/13] net/mlx5e: Fix missing IPsec statistics on uplink representor Saeed Mahameed
2021-12-01 6:36 ` [net 03/13] net/mlx5e: Sync TIR params updates against concurrent create/modify Saeed Mahameed
2021-12-01 6:37 ` [net 04/13] net/mlx5: Move MODIFY_RQT command to ignore list in internal error state Saeed Mahameed
2021-12-01 6:37 ` [net 05/13] net/mlx5: Lag, Fix recreation of VF LAG Saeed Mahameed
2021-12-01 6:37 ` [net 06/13] net/mlx5: E-switch, Respect BW share of the new group Saeed Mahameed
2021-12-01 6:37 ` [net 07/13] net/mlx5: E-Switch, fix single FDB creation on BlueField Saeed Mahameed
2021-12-01 6:37 ` [net 08/13] net/mlx5: E-Switch, Check group pointer before reading bw_share value Saeed Mahameed
2021-12-01 6:37 ` [net 09/13] net/mlx5: E-Switch, Use indirect table only if all destinations support it Saeed Mahameed
2021-12-01 6:37 ` [net 10/13] net/mlx5: Fix use after free in mlx5_health_wait_pci_up Saeed Mahameed
2021-12-01 6:37 ` [net 11/13] net/mlx5: Fix too early queueing of log timestamp work Saeed Mahameed
2021-12-01 6:37 ` [net 12/13] net/mlx5: Fix access to a non-supported register Saeed Mahameed
2021-12-01 6:37 ` Saeed Mahameed [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211201063709.229103-14-saeed@kernel.org \
--to=saeed@kernel.org \
--cc=benishay@nvidia.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=saeedm@nvidia.com \
--cc=tariqt@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).