Message ID | 20241031121411.20556-1-kirjanov@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | c009c955fdae64b3ae33f55be15832cad2a3592b |
Delegated to: | Stephen Hemminger |
Headers | show |
Series | [iproute2-next] lib: utils: close file handle on error | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
Hello: This patch was applied to iproute2/iproute2.git (main) by Stephen Hemminger <stephen@networkplumber.org>: On Thu, 31 Oct 2024 15:14:11 +0300 you wrote: > reap_prop() doesn't close the file descriptor > on some errors, fix it. > > Signed-off-by: Denis Kirjanov <kirjanov@gmail.com> > --- > lib/utils.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Here is the summary with links: - [iproute2-next] lib: utils: close file handle on error https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=c009c955fdae You are awesome, thank you!
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; }
reap_prop() doesn't close the file descriptor on some errors, fix it. Signed-off-by: Denis Kirjanov <kirjanov@gmail.com> --- lib/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)