[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241031121411.20556-1-kirjanov@gmail.com>
Date: Thu, 31 Oct 2024 15:14:11 +0300
From: Denis Kirjanov <kirjanov@...il.com>
To: stephen@...workplumber.org,
dsahern@...nel.org
Cc: netdev@...r.kernel.org,
Denis Kirjanov <kirjanov@...il.com>
Subject: [iproute2-next] lib: utils: close file handle on error
reap_prop() doesn't close the file descriptor
on some errors, fix it.
Signed-off-by: Denis Kirjanov <kirjanov@...il.com>
---
lib/utils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/utils.c b/lib/utils.c
index 66713251..aea4e8b7 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -73,7 +73,6 @@ int read_prop(const char *dev, char *prop, long *value)
if (!fgets(buf, sizeof(buf), fp)) {
fprintf(stderr, "property \"%s\" in file %s is currently unknown\n", prop, fname);
- fclose(fp);
goto out;
}
@@ -98,6 +97,7 @@ int read_prop(const char *dev, char *prop, long *value)
*value = result;
return 0;
out:
+ fclose(fp);
fprintf(stderr, "Failed to parse %s\n", fname);
return -1;
}
--
2.43.0
Powered by blists - more mailing lists