From: Maayan Kashani <mkashani@nvidia.com>
To: <dev@dpdk.org>
Cc: <mkashani@nvidia.com>, <dsosnowski@nvidia.com>,
<rasland@nvidia.com>, <stable@dpdk.org>,
Bing Zhao <bingz@nvidia.com>,
Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
Ori Kam <orika@nvidia.com>, Suanming Mou <suanmingm@nvidia.com>,
Matan Azrad <matan@nvidia.com>,
Gregory Etelson <getelson@nvidia.com>
Subject: [PATCH 2/2] net/mlx5: fix coverity warning
Date: Sun, 27 Apr 2025 14:22:57 +0300 [thread overview]
Message-ID: <20250427112257.108544-2-mkashani@nvidia.com> (raw)
In-Reply-To: <20250427112257.108544-1-mkashani@nvidia.com>
gre_item was dereferenced w/o checking it's value.
added a check to verify if null before using the pointer.
Fixes: 80c676259a04 ("net/mlx5: validate HWS template items")
Cc: stable@dpdk.org
Signed-off-by: Maayan Kashani <mkashani@nvidia.com>
Acked-by: Bing Zhao <bingz@nvidia.com>
---
drivers/net/mlx5/mlx5_flow.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index e2f4bd8cef1..93ee6f75626 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -3333,10 +3333,10 @@ mlx5_flow_validate_item_gre_key(const struct rte_eth_dev *dev,
return rte_flow_error_set(error, ENOTSUP,
RTE_FLOW_ERROR_TYPE_ITEM, item,
"GRE key following a wrong item");
- gre_mask = gre_item->mask;
+ gre_mask = gre_item ? gre_item->mask : NULL;
if (!gre_mask)
gre_mask = &rte_flow_item_gre_mask;
- gre_spec = gre_item->spec;
+ gre_spec = gre_item ? gre_item->spec : NULL;
if (gre_spec && (gre_mask->c_rsvd0_ver & RTE_BE16(0x2000)) &&
!(gre_spec->c_rsvd0_ver & RTE_BE16(0x2000)))
return rte_flow_error_set(error, EINVAL,
@@ -3379,8 +3379,8 @@ mlx5_flow_validate_item_gre_option(struct rte_eth_dev *dev,
const struct rte_flow_item *gre_item,
struct rte_flow_error *error)
{
- const struct rte_flow_item_gre *gre_spec = gre_item->spec;
- const struct rte_flow_item_gre *gre_mask = gre_item->mask;
+ const struct rte_flow_item_gre *gre_spec = gre_item ? gre_item->spec : NULL;
+ const struct rte_flow_item_gre *gre_mask = gre_item ? gre_item->mask : NULL;
const struct rte_flow_item_gre_opt *spec = item->spec;
const struct rte_flow_item_gre_opt *mask = item->mask;
struct mlx5_priv *priv = dev->data->dev_private;
--
2.21.0
prev parent reply other threads:[~2025-04-27 11:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-27 11:22 [PATCH 1/2] net/mlx5: non template - fix validation for GENEVE options Maayan Kashani
2025-04-27 11:22 ` Maayan Kashani [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=20250427112257.108544-2-mkashani@nvidia.com \
--to=mkashani@nvidia.com \
--cc=bingz@nvidia.com \
--cc=dev@dpdk.org \
--cc=dsosnowski@nvidia.com \
--cc=getelson@nvidia.com \
--cc=matan@nvidia.com \
--cc=orika@nvidia.com \
--cc=rasland@nvidia.com \
--cc=stable@dpdk.org \
--cc=suanmingm@nvidia.com \
--cc=viacheslavo@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).