File 0020-dlm_tool-fix-missing-fclose-calls.patch of Package libdlm
From e5ca08c20e6f530bfb95db67cbd62e6958f9af26 Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahringo@redhat.com>
Date: Thu, 30 Mar 2023 15:21:58 -0400
Subject: [PATCH 20/24] dlm_tool: fix missing fclose calls
This patch will fix missing fclose() calls when fgets() of do_lockdump()
fails.
---
dlm_tool/main.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/dlm_tool/main.c b/dlm_tool/main.c
index 52fd5b8974b8..2e6810d6da08 100644
--- a/dlm_tool/main.c
+++ b/dlm_tool/main.c
@@ -1177,8 +1177,9 @@ static void do_lockdump(char *name)
}
/* skip the header on the first line */
- if (!fgets(line, LOCK_LINE_MAX, file))
- return;
+ if (!fgets(line, LOCK_LINE_MAX, file)) {
+ goto out;
+ }
while (fgets(line, LOCK_LINE_MAX, file)) {
rv = sscanf(line, "%x %d %x %u %llu %x %x %hhd %hhd %hhd %u %d %d",
@@ -1199,7 +1200,7 @@ static void do_lockdump(char *name)
if (rv != 13) {
fprintf(stderr, "invalid debugfs line %d: %s\n",
rv, line);
- return;
+ goto out;
}
memset(r_name, 0, sizeof(r_name));
@@ -1229,6 +1230,7 @@ static void do_lockdump(char *name)
ownpid, nodeid, r_name);
}
+ out:
fclose(file);
}
--
2.35.3