From: Andy Moreton <[email protected]>

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: [email protected]

Signed-off-by: Andy Moreton <[email protected]>
Reviewed-by: Ivan Malov <[email protected]>
Reviewed-by: Viacheslav Galaktionov <[email protected]>
---
 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 d74604fd7c..a5003536c1 100644
--- a/drivers/common/sfc_efx/base/efx_np.c
+++ b/drivers/common/sfc_efx/base/efx_np.c
@@ -1162,7 +1162,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) {
@@ -1171,8 +1171,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

Reply via email to