Clamp l2_filter_count to 1 to `HW_ATL2_MAC_MAX - l2_filters_base_index`. One slot is required for the MAC address. The validation of the firmware supplied l2_filters_base_index ensures that at least 1 slot is avialable. The upper bound ensures that only valid L2 filter slots are programmed. Fixes: 6c1ca112a6e4 ("net: atlantic: fix AQC113 HW init: ART, L2 filter slot, MAC address") Cc: stab…@vger.kernel.org Signed-off-by: Janne Grunau <…@jannau.net> --- drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c index dc9b2ef4640b..38e9dd0477ed 100644 --- a/drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c +++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c @@ -4,6 +4,7 @@ */ #include <linux/iopoll.h> +#include <linux/minmax.h> #include "aq_hw.h" #include "aq_hw_utils.h" @@ -628,7 +629,8 @@ int hw_atl2_utils_get_filter_caps(struct aq_hw_s *self) priv->l2_filters_base_index = filter_caps.l2_filters_base_index; if (priv->l2_filters_base_index >= HW_ATL2_MAC_MAX) priv->l2_filters_base_index = HW_ATL2_MAC_UC; - priv->l2_filter_count = filter_caps.l2_filter_count; + priv->l2_filter_count = clamp(filter_caps.l2_filter_count, 1U, + HW_ATL2_MAC_MAX - priv->l2_filters_base_index); priv->etype_filter_base_index = filter_caps.ethertype_filter_base_index; priv->etype_filter_count = filter_caps.ethertype_filter_count; priv->etype_filter_tag_top =
-- 2.56.1