From: Sai Krishna <redacted>
pf2cgxlmac_map is allocated during CGX init to map RVU PFs to CGX
LMACs. When the bootloader does not provide RPM/firmware data, CGX
devices may be absent and the map is never allocated, leaving the
pointer NULL.
Several call paths use is_pf_cgxmapped() before indexing
pf2cgxlmac_map[], but the helper did not verify that the map exists.
Return false when pf2cgxlmac_map is NULL to avoid dereferencing it
in RPM-less configurations.
Fixes: 3a4fa841b039 ("octeontx2-af: Set RVU PFs to CGX LMACs mapping")
Signed-off-by: Sai Krishna <redacted>
Signed-off-by: Ratheesh Kannoth <rkannoth@marvell.com>
---
drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
index 094227404ef9..1e0a5aeb3f57 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
@@ -970,6 +970,9 @@ static inline int rvu_get_pf(struct pci_dev *pdev, u16 pcifunc)
/* CGX APIs */
static inline bool is_pf_cgxmapped(struct rvu *rvu, u8 pf)
{
+ if (!rvu->pf2cgxlmac_map)
+ return false;
+
return (pf >= PF_CGXMAP_BASE && pf <= rvu->cgx_mapped_pfs) &&
!is_sdp_pf(rvu, rvu_make_pcifunc(rvu->pdev, pf, 0));
}--
2.43.0