From c2915d3f8a077d72d359464369d220d7da71e6e0 Mon Sep 17 00:00:00 2001 From: Qi Zhang Date: Mon, 6 Jan 2020 11:38:46 +0800 Subject: [PATCH] net/ice/base: fix loop limit In ice_prot_type_to_id routine, correct the loop limit check to use ARRAY_SIZE instead of looking for the array element to have a specific value. Fixes: fed0c5ca5f19 ("net/ice/base: support programming a new switch recipe") Cc: stable@dpdk.org Signed-off-by: Dan Nowlin Signed-off-by: Paul M Stillwell Jr Signed-off-by: Qi Zhang Acked-by: Qiming Yang --- drivers/net/ice/base/ice_switch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ice/base/ice_switch.c b/drivers/net/ice/base/ice_switch.c index 3ed84ca016..b2945a9e2e 100644 --- a/drivers/net/ice/base/ice_switch.c +++ b/drivers/net/ice/base/ice_switch.c @@ -4880,7 +4880,7 @@ static bool ice_prot_type_to_id(enum ice_protocol_type type, u16 *id) { u16 i; - for (i = 0; ice_prot_id_tbl[i].type != ICE_PROTOCOL_LAST; i++) + for (i = 0; i < ARRAY_SIZE(ice_prot_id_tbl); i++) if (ice_prot_id_tbl[i].type == type) { *id = ice_prot_id_tbl[i].protocol_id; return true; -- 2.20.1