summaryrefslogtreecommitdiffstats
path: root/zebra/rtadv.c
diff options
context:
space:
mode:
authorMorgan Stewart <morgan@cumulusnetworks.com>2015-09-16 19:17:54 +0200
committerDaniel Walton <dwalton@cumulusnetworks.com>2016-05-26 17:33:32 +0200
commita5c304ab3583ce061b2d568077b7a33267eb8055 (patch)
tree078321c877938540c2b7a9e315ad7db01e6b5dcd /zebra/rtadv.c
parentzebra: fix addr sent in ZEBRA_IPV6_NEXTHOP_LOOKUP (diff)
downloadfrr-a5c304ab3583ce061b2d568077b7a33267eb8055.tar.xz
frr-a5c304ab3583ce061b2d568077b7a33267eb8055.zip
zebra: Fix leaked sockets in rtadv.c
Coverity Scan #709790 In zebra/rtadv.c: rtadv_make_socket leaks socket for error cases. Added lines to close the socket for each error case or return. Signed-off-by: Morgan Stewart <morgan@cumulusnetworks.com> (cherry picked from commit 26b663da7ea8a3efae816d6e7fda293bdc1082f5)
Diffstat (limited to 'zebra/rtadv.c')
-rw-r--r--zebra/rtadv.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/zebra/rtadv.c b/zebra/rtadv.c
index f9caa85b1..89087a9ec 100644
--- a/zebra/rtadv.c
+++ b/zebra/rtadv.c
@@ -630,23 +630,41 @@ rtadv_make_socket (void)
safe_strerror (errno) );
if (sock < 0)
- return -1;
+ {
+ close (sock);
+ return -1;
+ }
ret = setsockopt_ipv6_pktinfo (sock, 1);
if (ret < 0)
- return ret;
+ {
+ close (sock);
+ return ret;
+ }
ret = setsockopt_ipv6_multicast_loop (sock, 0);
if (ret < 0)
- return ret;
+ {
+ close (sock);
+ return ret;
+ }
ret = setsockopt_ipv6_unicast_hops (sock, 255);
if (ret < 0)
- return ret;
+ {
+ close (sock);
+ return ret;
+ }
ret = setsockopt_ipv6_multicast_hops (sock, 255);
if (ret < 0)
- return ret;
+ {
+ close (sock);
+ return ret;
+ }
ret = setsockopt_ipv6_hoplimit (sock, 1);
if (ret < 0)
- return ret;
+ {
+ close (sock);
+ return ret;
+ }
ICMP6_FILTER_SETBLOCKALL(&filter);
ICMP6_FILTER_SETPASS (ND_ROUTER_SOLICIT, &filter);