From: Denis Kirjanov Date: Thu, 31 Oct 2024 12:14:11 +0000 (+0300) Subject: lib: utils: close file handle on error X-Git-Tag: v6.13.0~15^2~3^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c009c955fdae64b3ae33f55be15832cad2a3592b;p=thirdparty%2Fiproute2.git 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 --- diff --git a/lib/utils.c b/lib/utils.c index 98c06ab6..5c67e006 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -70,7 +70,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; } @@ -95,6 +94,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; }