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@gmail.com>
This commit is contained in:
Denis Kirjanov 2024-10-31 15:14:11 +03:00 committed by Stephen Hemminger
parent d092468f11
commit c009c955fd

View 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;
}