DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: ciara.loftus@intel.com, Bruce Richardson <bruce.richardson@intel.com>
Subject: [PATCH] net/iavf: check for NULL pointer before dereference
Date: Fri, 10 Jul 2026 13:59:40 +0100	[thread overview]
Message-ID: <20260710125940.1572978-1-bruce.richardson@intel.com> (raw)

Static analysis with Coverity flags a possible NULL pointer dereference
of "hdr1" when handling IPv4 or IPv6 fragements in
iavf_fdir_parse_pattern.  This is likely a false positive, since the
flow pattern protocol sequences are checked before this function is
called, so all paths leading to a hdr1 dereference start with an
ethernet protocol, which sets hdr1 to a non-NULL value.

However, this is a rather brittle situation, so to prevent any future
issues if a new set of allowed protocols is added with IP but no
Ethernet matching patterns, add explicit NULL checks for hdr1 before
it's used each time.

Coverity Id: 503768

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/intel/iavf/iavf_fdir.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/net/intel/iavf/iavf_fdir.c b/drivers/net/intel/iavf/iavf_fdir.c
index 8940132dff..ea620863ca 100644
--- a/drivers/net/intel/iavf/iavf_fdir.c
+++ b/drivers/net/intel/iavf/iavf_fdir.c
@@ -806,6 +806,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 				 * ethertype, if the spec and mask is valid,
 				 * set ethertype into input set.
 				 */
+				/* ETH should be present via pattern pre-validation. */
+				if (hdr1 == NULL) {
+					rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item,
+						   "Missing ETH header before IPv4 fragment.");
+					return -rte_errno;
+				}
 				input_set |= IAVF_INSET_ETHERTYPE;
 				VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr1, ETH,
 								 ETHERTYPE);
@@ -911,6 +919,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 				 * ethertype, if the spec and mask is valid,
 				 * set ethertype into input set.
 				 */
+				/* ETH should be present via pattern pre-validation. */
+				if (hdr1 == NULL) {
+					rte_flow_error_set(error, EINVAL,
+						   RTE_FLOW_ERROR_TYPE_ITEM,
+						   item,
+						   "Missing ETH header before IPv6 fragment.");
+					return -rte_errno;
+				}
 				input_set |= IAVF_INSET_ETHERTYPE;
 				VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr1, ETH,
 								 ETHERTYPE);
-- 
2.53.0


             reply	other threads:[~2026-07-10 12:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-10 12:59 Bruce Richardson [this message]
2026-07-10 13:19 ` [PATCH] net/iavf: check for NULL pointer before dereference Loftus, Ciara
2026-07-10 14:16   ` Bruce Richardson

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=20260710125940.1572978-1-bruce.richardson@intel.com \
    --to=bruce.richardson@intel.com \
    --cc=ciara.loftus@intel.com \
    --cc=dev@dpdk.org \
    /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