[PATCH 12/14] common/sfc_efx/base: fix filter in SW-HW mask converter

Ivan Malov ivan.malov at arknetworks.am
Tue Aug 11 19:48:19 CEST 2026


From: Andy Moreton <andy.moreton at amd.com>

Code analysis reports that the optional filter_arg could be used to invoke
the callback, but that function has type efx_np_cap_filter_cb, where the
argument is required. Add a NULL check to ensure that the filter_arg
is valid when invoking the callback.

Fixes: b50ff442479c ("common/sfc_efx/base: support controls for netport lane count")
Cc: stable at dpdk.org

Signed-off-by: Andy Moreton <andy.moreton at amd.com>
Reviewed-by: Ivan Malov <ivan.malov at arknetworks.am>
Reviewed-by: Viacheslav Galaktionov <viacheslav.galaktionov at arknetworks.am>
---
 drivers/common/sfc_efx/base/efx_np.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/common/sfc_efx/base/efx_np.c b/drivers/common/sfc_efx/base/efx_np.c
index af06c10ecc..180f24c8e5 100644
--- a/drivers/common/sfc_efx/base/efx_np.c
+++ b/drivers/common/sfc_efx/base/efx_np.c
@@ -1160,7 +1160,7 @@ efx_np_cap_mask_sw_to_hw(
 	__in				uint32_t mask_sw,
 	__in_opt			efx_np_cap_filter_cb *filter_cb,
 	__in_opt			void *filter_arg,
-	__out				uint8_t *mask_hwp)
+	__inout				uint8_t *mask_hwp)
 {
 	FOREACH_SUP_CAP(hw_sw_map, hw_sw_map_nentries,
 	    hw_cap_data, hw_cap_data_nbytes) {
@@ -1169,8 +1169,8 @@ efx_np_cap_mask_sw_to_hw(
 		if ((mask_sw & flag_sw) != flag_sw)
 			continue;
 
-		if (filter_cb != NULL &&
-		    filter_cb(hw_sw_map->encm_hw, filter_arg) == B_FALSE)
+		if ((filter_cb != NULL) && (filter_arg != NULL) &&
+		    (filter_cb(hw_sw_map->encm_hw, filter_arg) == B_FALSE))
 			continue;
 
 		mask_hwp[CAP_BYTE(hw_sw_map)] |= CAP_FLAG(hw_sw_map);
-- 
2.47.3



More information about the dev mailing list