Static analysis reports that a rule dump may trigger NULL dereference. This
cannot actually happen because dump_blob will not dereference the rule_data
when rule_size is 0, but it's a good defensive check anyway, so add it.

Coverity issue: 503773

Fixes: 51f505a4090f ("net/ixgbe: support flow dump")

Signed-off-by: Anatoly Burakov <[email protected]>
---
 drivers/net/intel/ixgbe/ixgbe_flow.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/net/intel/ixgbe/ixgbe_flow.c 
b/drivers/net/intel/ixgbe/ixgbe_flow.c
index 19d7f93d93..6868893d46 100644
--- a/drivers/net/intel/ixgbe/ixgbe_flow.c
+++ b/drivers/net/intel/ixgbe/ixgbe_flow.c
@@ -3345,11 +3345,18 @@ ixgbe_flow_dev_dump(struct rte_eth_dev *dev,
                if (flow != NULL && p_flow != flow)
                        continue;
 
+               /* this should not happen */
+               if (p_flow->rule == NULL) {
+                       PMD_DRV_LOG(DEBUG, "Invalid flow");
+                       continue;
+               }
+
+               rule_size = ixgbe_flow_rule_size(p_flow);
+               if (rule_size == 0)
+                       continue;
+
                found = true;
-               if (p_flow->rule != NULL) {
-                       rule_data = ixgbe_flow_rule_data(p_flow);
-                       rule_size = ixgbe_flow_rule_size(p_flow);
-               }
+               rule_data = ixgbe_flow_rule_data(p_flow);
                engine_name = ixgbe_flow_rule_engine_name(p_flow);
                ixgbe_flow_dump_blob(file, engine_name,
                        rule_data, rule_size);
-- 
2.47.3

Reply via email to