[lxc-devel] [lxc/master] Fixed resource leak in is_wlan() at network.c

simos on Github lxc-bot at linuxcontainers.org
Tue May 15 00:37:17 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 452 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180515/3ba7e28d/attachment.bin>
-------------- next part --------------
From 0a96cc7e4b330e9351f018568af7d551d567bba4 Mon Sep 17 00:00:00 2001
From: Simos Xenitellis <simos.lists at googlemail.com>
Date: Tue, 15 May 2018 00:05:13 +0000
Subject: [PATCH] Fixed resource leak in is_wlan() at network.c

coverity: #1248106

Signed-off-by: Simos Xenitellis <simos.lists at googlemail.com>
---
 src/lxc/network.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/lxc/network.c b/src/lxc/network.c
index a7e05280d..835a1fb69 100644
--- a/src/lxc/network.c
+++ b/src/lxc/network.c
@@ -591,8 +591,10 @@ static char *is_wlan(const char *ifname)
 	fseek(f, 0, SEEK_END);
 	physlen = ftell(f);
 	fseek(f, 0, SEEK_SET);
-	if (physlen < 0)
+	if (physlen < 0) {
+		fclose(f);
 		goto bad;
+	}
 
 	physname = malloc(physlen + 1);
 	if (!physname) {


More information about the lxc-devel mailing list