]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
coverity: fix a resource leak
authorVincent Bernat <bernat@luffy.cx>
Fri, 22 Nov 2013 22:09:33 +0000 (23:09 +0100)
committerVincent Bernat <bernat@luffy.cx>
Fri, 22 Nov 2013 22:10:48 +0000 (23:10 +0100)
In `netlink.c`, ensure we free the socket if we have a memory allocation
problem.

src/daemon/netlink.c

index 1f0611fb145c0864ef490b6e8110be2732299ae8..3168554a85e54ad7e7374102f694946530a90143 100644 (file)
@@ -362,6 +362,7 @@ netlink_get_interfaces()
     ifs = malloc(sizeof(struct interfaces_device_list));
     if (ifs == NULL) {
         log_warn("netlink", "not enough memory for interface list");
+        close(s);
         return NULL;
     }
     TAILQ_INIT(ifs);
@@ -411,6 +412,7 @@ netlink_get_addresses()
     ifaddrs = malloc(sizeof(struct interfaces_address_list));
     if (ifaddrs == NULL) {
         log_warn("netlink", "not enough memory for address list");
+        close(s);
         return NULL;
     }
     TAILQ_INIT(ifaddrs);