[PATCH] gdhcp: Fix resource leak

Danny Jeongseok Seo s.seo at samsung.com
Thu Nov 8 21:42:50 PST 2012


The socket was not closed when the sendto got failed.
---
 gdhcp/ipv4ll.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gdhcp/ipv4ll.c b/gdhcp/ipv4ll.c
index 17ab3d5..283bb9b 100644
--- a/gdhcp/ipv4ll.c
+++ b/gdhcp/ipv4ll.c
@@ -110,11 +110,12 @@ int ipv4ll_send_arp_packet(uint8_t* source_eth, uint32_t source_ip,
 
 	n = sendto(fd, &p, sizeof(p), 0,
 	       (struct sockaddr*) &dest, sizeof(dest));
-	if (n < 0)
-		return -errno;
 
 	close(fd);
 
+	if (n < 0)
+		return -errno;
+
 	return n;
 }
 
-- 
1.7.10.4




More information about the connman mailing list