Blame SOURCES/0003-Don-t-leak-our-socket-s-fd-when-determining-network-.patch

5fb29d
From 611460349c214d9655a4ee06757fbcb5bdf6e2a3 Mon Sep 17 00:00:00 2001
5fb29d
From: Peter Jones <pjones@redhat.com>
5fb29d
Date: Wed, 10 Sep 2014 15:32:59 -0400
5fb29d
Subject: [PATCH 03/18] Don't leak our socket's fd when determining network
5fb29d
 info.
5fb29d
5fb29d
Covscan again.
5fb29d
5fb29d
Signed-off-by: Peter Jones <pjones@redhat.com>
5fb29d
---
5fb29d
 src/lib/efi.c | 8 +++++++-
5fb29d
 1 file changed, 7 insertions(+), 1 deletion(-)
5fb29d
5fb29d
diff --git a/src/lib/efi.c b/src/lib/efi.c
5fb29d
index 6b25dfe..8ba0e54 100644
5fb29d
--- a/src/lib/efi.c
5fb29d
+++ b/src/lib/efi.c
5fb29d
@@ -631,13 +631,16 @@ make_net_load_option(char *iface, uint8_t *buf, size_t size)
5fb29d
 	err = ioctl(fd, SIOCETHTOOL, &ifr);
5fb29d
 	if (err < 0) {
5fb29d
 		perror("Cannot get driver information");
5fb29d
+		close(fd);
5fb29d
 		return -1;
5fb29d
 	}
5fb29d
 
5fb29d
 	if (strncmp(drvinfo.bus_info, "virtio", 6) == 0) {
5fb29d
 		err = get_virt_pci(drvinfo.bus_info, &bus, &slot, &func);
5fb29d
-		if (err < 0)
5fb29d
+		if (err < 0) {
5fb29d
+			close(fd);
5fb29d
 			return err;
5fb29d
+		}
5fb29d
 	} else {
5fb29d
 		/* The domain part was added in 2.6 kernels.
5fb29d
 		 * Test for that first. */
5fb29d
@@ -648,6 +651,7 @@ make_net_load_option(char *iface, uint8_t *buf, size_t size)
5fb29d
 						&bus, &slot, &func);
5fb29d
 			if (err != 3) {
5fb29d
 				perror("Couldn't parse device location string.");
5fb29d
+				close(fd);
5fb29d
 				return -1;
5fb29d
 			}
5fb29d
 		}
5fb29d
@@ -655,9 +659,11 @@ make_net_load_option(char *iface, uint8_t *buf, size_t size)
5fb29d
 
5fb29d
 	err = ioctl(fd, SIOCGIFHWADDR, &ifr);
5fb29d
 	if (err < 0) {
5fb29d
+		close(fd);
5fb29d
 		perror("Cannot get hardware address.");
5fb29d
 		return -1;
5fb29d
 	}
5fb29d
+	close(fd);
5fb29d
 
5fb29d
 	buf_offset = 0;
5fb29d
 	needed = make_acpi_device_path(opts.acpi_hid, opts.acpi_uid, buf,
5fb29d
-- 
5fb29d
1.9.3
5fb29d