From b57c376033244605b39291f101874ea2ac032b35 Mon Sep 17 00:00:00 2001 From: Shuotian Cheng Date: Thu, 10 May 2018 01:40:12 -0700 Subject: [PATCH] [teamsyncd]: Add team_ifindex2ifname return value check (#500) Without the return value check, it is possible that ifname is empty due to interface not found. Signed-off-by: Shu0T1an ChenG --- teamsyncd/teamsync.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/teamsyncd/teamsync.cpp b/teamsyncd/teamsync.cpp index d3fb222d5c0f..71a7137eb731 100644 --- a/teamsyncd/teamsync.cpp +++ b/teamsyncd/teamsync.cpp @@ -160,11 +160,19 @@ int TeamSync::TeamPortSync::onChange() bool enabled; ifindex = team_get_port_ifindex(port); - team_ifindex2ifname(m_team, ifindex, ifname, MAX_IFNAME); + + /* Skip if interface is not found */ + if (!team_ifindex2ifname(m_team, ifindex, ifname, MAX_IFNAME)) + { + SWSS_LOG_INFO("Interface ifindex(%u) is not found", ifindex); + continue; + } /* Skip the member that is removed from the LAG */ if (team_is_port_removed(port)) + { continue; + } team_get_port_enabled(m_team, ifindex, &enabled); tmp_lag_members[string(ifname)] = enabled;