Skip to contentSkip to conversation

common/cnxk: fix inline dev null dereference

PATCH Applied Aarnav JP 2 participants 2 messages Jun 23

lore
Share & tools
lore

Aarnav JP

author
#0 lore raw

PATCH 1/1 common/cnxk: fix inline dev null dereference

inl_dev is initialized to NULL and only assigned within the if (idev && idev->nix_inl_dev) block.
Move inl_dev->res_addr_offset and inl_dev->cpt_cq_ena accesses inside this null-guarded block in nix_inl_inb_ipsec_sa_tbl_setup() and nix_inl_reass_inb_sa_tbl_setup() to avoid dereferencing a null pointer.

Fixes 3fdf3e53f3c4 ("common/cnxk: enable CPT CQ for inline IPsec inbound")
---
 drivers/common/cnxk/roc_nix_inl.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/common/cnxk/roc_nix_inl.c +5 -6
index db101e71a5..935dd37778 100644
@@ -409,7 +409,7 @@ nix_inl_inb_ipsec_sa_tbl_setup(struct roc_nix *roc_nix)
 	struct nix_inl_dev *inl_dev = NULL;
 	uint64_t max_sa, i, sa_pow2_sz;
 	uint64_t sa_idx_w, lenm1_max;
-	uint64_t res_addr_offset;
+	uint64_t res_addr_offset = 0;
 	uint8_t profile_id = 0;
 	struct mbox *mbox;
 	size_t inb_sa_sz;
@@ -503,13 +503,12 @@ nix_inl_inb_ipsec_sa_tbl_setup(struct roc_nix *roc_nix)
 				def_cptq = 0;
 			else
 				def_cptq = inl_dev->nix_inb_qids[inl_dev->inb_cpt_lf_id];
+			res_addr_offset = (uint64_t)(inl_dev->res_addr_offset & 0xFF) << 48;
+			if (res_addr_offset)
+				res_addr_offset |= (1UL << 56);
+			cpt_cq_ena = (uint64_t)inl_dev->cpt_cq_ena << 63;
 		}
 
-		res_addr_offset = (uint64_t)(inl_dev->res_addr_offset & 0xFF) << 48;
-		if (res_addr_offset)
-			res_addr_offset |= (1UL << 56);
-
-		cpt_cq_ena = (uint64_t)inl_dev->cpt_cq_ena << 63;
 		lf_cfg->enable = 1;
 		lf_cfg->profile_id = profile_id; /* IPsec profile is 0th one */
 		lf_cfg->rx_inline_sa_base = (uintptr_t)nix->inb_sa_base[profile_id] | cpt_cq_ena;
Signature · 1 line
2.43.0
Applied
#1 lore raw
Quoted 8 lines · Aarnav JP

inl_dev is initialized to NULL and only assigned within the if (idev && idev->nix_inl_dev) block.
Move inl_dev->res_addr_offset and inl_dev->cpt_cq_ena accesses inside this null-guarded block in nix_inl_inb_ipsec_sa_tbl_setup() and nix_inl_reass_inb_sa_tbl_setup() to avoid dereferencing a null pointer.

Quoted 4 lines
Fixes 3fdf3e53f3c4 ("common/cnxk: enable CPT CQ for inline IPsec inbound")

Applied to dpdk-next-net-mrvl/for-main. Thanks