find_entry is left uninitialized if no pre-tunnel slot is in
use, and is NULL if no slot matches this representor's MAC.
Either case is then dereferenced when computing nfp_mac_idx.

Initialize find_entry and fail the delete if no entry is found.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: d3c33bdf1f18 ("net/nfp: prepare for IPv4 UDP tunnel decap flow action")
Cc: [email protected]

Signed-off-by: Mark Bulatov <[email protected]>
---
v3 changes: The check was moved to a higher level, and
the description was corrected.

v2 link:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/
v2 changes: Correction of the Fixes tag and addition of find_entry
initialization at the point of declaration

v1 link:
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

 drivers/net/nfp/flower/nfp_flower_flow.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c 
b/drivers/net/nfp/flower/nfp_flower_flow.c
index ad0fe9a8ef..9dbf9b934a 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -3793,7 +3793,7 @@ nfp_pre_tun_table_check_del(struct nfp_flower_representor 
*repr,
        uint16_t nfp_mac_idx;
        struct nfp_flow_priv *priv;
        struct nfp_pre_tun_entry *entry;
-       struct nfp_pre_tun_entry *find_entry;
+       struct nfp_pre_tun_entry *find_entry = NULL;
        struct nfp_fl_rule_metadata *nfp_flow_meta;
 
        priv = repr->app_fw_flower->flow_priv;
@@ -3827,6 +3827,12 @@ nfp_pre_tun_table_check_del(struct 
nfp_flower_representor *repr,
                }
        }
 
+       if (find_entry == NULL) {
+               PMD_DRV_LOG(ERR, "Pre-tunnel table entry not found.");
+               ret = -EINVAL;
+               goto free_entry;
+       }
+
        nfp_flow_meta = nfp_flow->payload.meta;
        nfp_mac_idx = (find_entry->mac_index << 8) |
                        NFP_FLOWER_CMSG_PORT_TYPE_OTHER_PORT |
-- 
2.39.5

Reply via email to