Static analysis reports that a rule might have a valid engine but invalid
rule pointer while having a valid rule size. This should not happen in
normal operation, but it's a good defensive check, so fix the potential
issue by checking for the problematic condition before dumping flow memory.
Coverity issue: 503764
Fixes: 32251f047e92 ("net/iavf: support flow dump")
Signed-off-by: Anatoly Burakov <[email protected]>
---
drivers/net/intel/iavf/iavf_generic_flow.c | 23 ++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/drivers/net/intel/iavf/iavf_generic_flow.c
b/drivers/net/intel/iavf/iavf_generic_flow.c
index 8bd874c32a..84bb161bd1 100644
--- a/drivers/net/intel/iavf/iavf_generic_flow.c
+++ b/drivers/net/intel/iavf/iavf_generic_flow.c
@@ -2414,18 +2414,21 @@ iavf_flow_dev_dump(struct rte_eth_dev *dev,
if (flow != NULL && f != flow)
continue;
+ /* this should not happen */
+ if (f->engine == NULL || f->rule == NULL) {
+ PMD_DRV_LOG(DEBUG, "Invalid flow");
+ continue;
+ }
+
found = true;
- if (f->engine != NULL) {
- rule_size = f->engine->rule_size;
- if (f->rule != NULL)
- rule_data = f->rule;
- }
- if (f->engine != NULL)
- iavf_flow_dump_blob(file,
- f->engine->name != NULL ?
- f->engine->name : "unknown",
- rule_data, rule_size);
+ rule_size = f->engine->rule_size;
+ rule_data = f->rule;
+
+ iavf_flow_dump_blob(file,
+ f->engine->name != NULL ?
+ f->engine->name : "unknown",
+ rule_data, rule_size);
}
rte_spinlock_unlock(&vf->flow_ops_lock);
--
2.47.3