Static analysis reports that a rule dump may trigger NULL dereference when
rule pointer is NULL. This should not happen under normal circumstances as
0 sized rule would not dereference the rule data pointer due to chunking,
but it's a good defensive check, so add it.

Coverity issue: 503771

Fixes: ffaddd0fa935 ("net/i40e: support flow dump")

Signed-off-by: Anatoly Burakov <[email protected]>
---
 drivers/net/intel/i40e/i40e_flow.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/net/intel/i40e/i40e_flow.c 
b/drivers/net/intel/i40e/i40e_flow.c
index 1051c99fba..142cfb5150 100644
--- a/drivers/net/intel/i40e/i40e_flow.c
+++ b/drivers/net/intel/i40e/i40e_flow.c
@@ -1276,11 +1276,19 @@ i40e_flow_dev_dump(struct rte_eth_dev *dev,
                if (flow != NULL && p_flow != flow)
                        continue;
 
+               /* should not happen */
+               if (p_flow->rule == NULL) {
+                       PMD_DRV_LOG(DEBUG, "Invalid flow rule");
+                       continue;
+               }
+
+               rule_size = i40e_flow_rule_size(p_flow->filter_type);
+               /* should not happen either */
+               if (rule_size == 0)
+                       continue;
+
                found = true;
-               if (p_flow->rule != NULL) {
-                       rule_size = i40e_flow_rule_size(p_flow->filter_type);
-                       rule_data = p_flow->rule;
-               }
+               rule_data = p_flow->rule;
                i40e_flow_dump_blob(file,
                        i40e_flow_rule_name(p_flow->filter_type),
                        rule_data, rule_size);
-- 
2.47.3

Reply via email to