From: Mark Bulatov <[email protected]>

If the search fails, it leads to a null pointer dereference when attempting
to initialize nfp_mac_idx.

Fix this by adding a check.

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

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

Signed-off-by: Mark Bulatov <[email protected]>
---
 drivers/net/nfp/flower/nfp_flower_flow.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c 
b/drivers/net/nfp/flower/nfp_flower_flow.c
index ad0fe9a8ef..b70f24c1fb 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -3828,6 +3828,13 @@ nfp_pre_tun_table_check_del(struct 
nfp_flower_representor *repr,
        }
 
        nfp_flow_meta = nfp_flow->payload.meta;
+
+       if (find_entry == NULL) {
+               PMD_DRV_LOG(ERR, "Pre-tunnel table search failed.");
+               ret = -EINVAL;
+               goto free_entry;
+       }
+
        nfp_mac_idx = (find_entry->mac_index << 8) |
                        NFP_FLOWER_CMSG_PORT_TYPE_OTHER_PORT |
                        NFP_TUN_PRE_TUN_IDX_BIT;
-- 
2.39.5

Reply via email to