From 85eec204a15ebfa07ef121955e66dcfe7aa46208 Mon Sep 17 00:00:00 2001 From: Hasti M Gondaliya Date: Fri, 22 Sep 2023 17:51:51 +0530 Subject: [PATCH] [Coverity]: Argument cannot be negative Added validation to check for the negetive value of sMLDMonitorFd, as setsockopt parameter cannot be negative --- src/posix/platform/netif.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/posix/platform/netif.cpp b/src/posix/platform/netif.cpp index 1cf73e23580..79aa7d1769e 100644 --- a/src/posix/platform/netif.cpp +++ b/src/posix/platform/netif.cpp @@ -1725,6 +1725,8 @@ static void mldListenerInit(void) struct ipv6_mreq mreq6; sMLDMonitorFd = SocketWithCloseExec(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6, kSocketNonBlock); + VerifyOrDie(sMLDMonitorFd != -1, OT_EXIT_FAILURE); + mreq6.ipv6mr_interface = gNetifIndex; memcpy(&mreq6.ipv6mr_multiaddr, kMLDv2MulticastAddress.mFields.m8, sizeof(kMLDv2MulticastAddress.mFields.m8));