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.12.0~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d7d395ebb228896bc2d382f646fbc83e7488e245;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 Signed-off-by: Stephen Hemminger --- 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; }