]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
lib: utils: close file handle on error
authorDenis Kirjanov <kirjanov@gmail.com>
Thu, 31 Oct 2024 12:14:11 +0000 (15:14 +0300)
committerStephen Hemminger <stephen@networkplumber.org>
Wed, 6 Nov 2024 17:11:35 +0000 (09:11 -0800)
reap_prop() doesn't close the file descriptor
on some errors, fix it.

Signed-off-by: Denis Kirjanov <kirjanov@gmail.com>
lib/utils.c

index 98c06ab6a652eb24632987ea0ec04c9ab6f8220f..5c67e00605cf1417b5b178acece1da01673e5447 100644 (file)
@@ -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;
 }