From 79ebf718b9a2cf1b95a903f69059f0452e0f1144 Mon Sep 17 00:00:00 2001 From: Deepak-Rathn Date: Mon, 19 Oct 2026 14:08:00 +0000 Subject: [PATCH] RDKB-67402: [Coverity] Fix High and Medium Priority issues in hotspot component Reason for change: Fixing Coverity issue linked in Jira Test Procedure: Should meet Acceptance Criteria: Risks: Medium Priority: P1 Signed-off-by: Deepak-Rathn --- source/HotspotApi/HotspotApi.c | 11 +++++--- source/arp_solicitation/hotspot_arpd.c | 28 +++++++++++--------- source/hotspotfd/hotspotfd.c | 36 ++++++++++++++++---------- 3 files changed, 47 insertions(+), 28 deletions(-) diff --git a/source/HotspotApi/HotspotApi.c b/source/HotspotApi/HotspotApi.c index e54a9ae..05e7560 100644 --- a/source/HotspotApi/HotspotApi.c +++ b/source/HotspotApi/HotspotApi.c @@ -198,8 +198,10 @@ void firewall_restart() { static int hotspot_sysevent_disable_param(){ - sysevent_get(gSyseventfd, gSysevent_token, "hotspot_1-status", - NULL, 0); + if(0 != sysevent_get(gSyseventfd, gSysevent_token, "hotspot_1-status", NULL, 0)) + { + return 1; + } return 0; } @@ -1214,7 +1216,10 @@ pErr setHotspot(void* const network){ else{ CcspTraceInfo(("HOTSPOT_LIB : Gre is not enabled. Deleting tunnel info \n")); deleteVaps(); - hotspot_sysevent_disable_param(); + if(hotspot_sysevent_disable_param()) + { + CcspTraceInfo(("HOTSPOT_LIB : sysevent_get failed for hotspot_1-status \n")); + } memset(vlanIdList, '\0', sizeof(vlanIdList)); memset(gPriEndptIP, '\0', sizeof(gPriEndptIP)); memset(gSecEndptIP, '\0', sizeof(gSecEndptIP)); diff --git a/source/arp_solicitation/hotspot_arpd.c b/source/arp_solicitation/hotspot_arpd.c index 0a06ec3..4959a28 100644 --- a/source/arp_solicitation/hotspot_arpd.c +++ b/source/arp_solicitation/hotspot_arpd.c @@ -351,18 +351,22 @@ static int get_interface_by_ifname(if_t *target) if(sysevent_fd_gs >= 0) { - sysevent_get(sysevent_fd_gs, sysevent_token_gs, SYSEVENT_MAPT_CONFIG_FLAG, buf, sizeof(buf)); - - if (strncmp(buf,"set", 3) == 0) - { - sysevent_get(sysevent_fd_gs, sysevent_token_gs, SYSEVENT_MAPT_IP_ADDRESS, buf, sizeof(buf)); - - if(inet_aton(buf,&(target->ip))) - { - mapt_ipv4 = 1; - } - } - sysevent_close(sysevent_fd_gs, sysevent_token_gs); + if(0 == sysevent_get(sysevent_fd_gs, sysevent_token_gs, SYSEVENT_MAPT_CONFIG_FLAG, buf, sizeof(buf))) + { + if (strncmp(buf,"set", 3) == 0) + { + if(0 == sysevent_get(sysevent_fd_gs, sysevent_token_gs, SYSEVENT_MAPT_IP_ADDRESS, buf, sizeof(buf))) + { + if(inet_aton(buf,&(target->ip))) + { + mapt_ipv4 = 1; + } + } + } + } + sysevent_close(sysevent_fd_gs, sysevent_token_gs); + sysevent_fd_gs = -1; + sysevent_token_gs = 0; } #endif if(0 == mapt_ipv4) diff --git a/source/hotspotfd/hotspotfd.c b/source/hotspotfd/hotspotfd.c index 3163509..77bf0c0 100644 --- a/source/hotspotfd/hotspotfd.c +++ b/source/hotspotfd/hotspotfd.c @@ -722,7 +722,7 @@ STATIC unsigned short hotspotfd_checksum(void *pdata, int len) sum = (sum >> 16) + (sum & 0xFFFF); sum += (sum >> 16); - result = ~sum; + result = (unsigned short)((~sum) & 0xFFFFU); return result; } @@ -1261,10 +1261,9 @@ STATIC void *hotspotfd_sysevent_handler(void *data) msg_debug("gpPrimaryEP: %s\n", gpPrimaryEP); - CcspTraceInfo((" GRE flag set to %d in sysevent handler \n", gbFirstPrimarySignal)); - pthread_mutex_lock(&keep_alive_mutex); gbFirstPrimarySignal = true; + CcspTraceInfo((" GRE flag set to %d in sysevent handler \n", gbFirstPrimarySignal)); pthread_mutex_unlock(&keep_alive_mutex); } else if (ret_value == HOTSPOTFD_SECONDARY) { rc = strcpy_s(gpSecondaryEP, sizeof(gpSecondaryEP), val); @@ -2172,7 +2171,17 @@ void hotspot_start() hotspotfd_log(); } + bool processFirstPrimarySignal = false; + + pthread_mutex_lock(&keep_alive_mutex); if (gbFirstPrimarySignal) { + gbFirstPrimarySignal = false; + processFirstPrimarySignal = true; + CcspTraceInfo(("Primary GRE flag set to %d\n", gbFirstPrimarySignal)); + } + pthread_mutex_unlock(&keep_alive_mutex); + + if (processFirstPrimarySignal) { if(ssid_reset_mask != 0) { @@ -2212,10 +2221,6 @@ void hotspot_start() #endif gTunnelIsUp=true; - pthread_mutex_lock(&keep_alive_mutex); - gbFirstPrimarySignal = false; - pthread_mutex_unlock(&keep_alive_mutex); - CcspTraceInfo(("Primary GRE flag set to %d\n", gbFirstPrimarySignal)); if(switchedFromSecondary) { gSwitchedBackToPrimary++; @@ -2369,9 +2374,18 @@ void hotspot_start() else { CcspTraceInfo(("SSID's are not updated after tunnel deletion. \n")); } - } + } + + bool processFirstSecondarySignal = false; + pthread_mutex_lock(&keep_alive_mutex); if (gbFirstSecondarySignal) { + gbFirstSecondarySignal = false; + processFirstSecondarySignal = true; + } + pthread_mutex_unlock(&keep_alive_mutex); + + if (processFirstSecondarySignal) { CcspTraceInfo(("Create Secondary GRE tunnel with endpoint:%s\n", gpSecondaryEP)); if (sysevent_set(sysevent_fd_gs, sysevent_token_gs, @@ -2389,11 +2403,7 @@ void hotspot_start() #if (defined (_COSA_BCM_ARM_) && !defined(_XB6_PRODUCT_REQ_)) hotspotfd_syncMultinet(); #endif - gTunnelIsUp=true; - - pthread_mutex_lock(&keep_alive_mutex); - gbFirstSecondarySignal = false; - pthread_mutex_unlock(&keep_alive_mutex); + gTunnelIsUp=true; } msg_debug("Secondary GRE Tunnel Endpoint is alive\n");