[PATCH] kexec:Add some necessary fclose() calls
Kai Song
songkai01 at inspur.com
Wed Sep 29 01:08:44 PDT 2021
fclose should be called before function exits
Signed-off-by: Kai Song <songkai01 at inspur.com>
---
kexec/arch/ppc/fixup_dtb.c | 2 ++
kexec/arch/ppc64/crashdump-ppc64.c | 1 +
kexec/arch/ppc64/kexec-ppc64.c | 4 +++-
kexec/symbols.c | 2 ++
4 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/kexec/arch/ppc/fixup_dtb.c b/kexec/arch/ppc/fixup_dtb.c
index 4524c8c..92a0bfd 100644
--- a/kexec/arch/ppc/fixup_dtb.c
+++ b/kexec/arch/ppc/fixup_dtb.c
@@ -382,6 +382,8 @@ static void save_fixed_up_dtb(char *blob_buf, off_t blob_size)
} else {
dbgprintf("Unable to write debug.dtb\n");
}
+
+ fclose(fp);
} else {
dbgprintf("Unable to dump flat device tree to debug.dtb\n");
}
diff --git a/kexec/arch/ppc64/crashdump-ppc64.c b/kexec/arch/ppc64/crashdump-ppc64.c
index addd769..91f9521 100644
--- a/kexec/arch/ppc64/crashdump-ppc64.c
+++ b/kexec/arch/ppc64/crashdump-ppc64.c
@@ -161,6 +161,7 @@ static int get_dyn_reconf_crash_memory_ranges(void)
fprintf(stderr,
"Error: Number of crash memory ranges"
" excedeed the max limit\n");
+ fclose(file);
return -1;
}
diff --git a/kexec/arch/ppc64/kexec-ppc64.c b/kexec/arch/ppc64/kexec-ppc64.c
index 4e70b13..5b17740 100644
--- a/kexec/arch/ppc64/kexec-ppc64.c
+++ b/kexec/arch/ppc64/kexec-ppc64.c
@@ -200,8 +200,10 @@ static int get_dyn_reconf_base_ranges(void)
fclose(file);
return -1;
}
- if (nr_memory_ranges >= max_memory_ranges)
+ if (nr_memory_ranges >= max_memory_ranges) {
+ fclose(file);
return -1;
+ }
/*
* If the property is ibm,dynamic-memory-v2, the first 4 bytes
diff --git a/kexec/symbols.c b/kexec/symbols.c
index e88f7f3..04377ca 100644
--- a/kexec/symbols.c
+++ b/kexec/symbols.c
@@ -24,11 +24,13 @@ unsigned long long get_kernel_sym(const char *symbol)
if (strcmp(sym, symbol) == 0) {
dbgprintf("kernel symbol %s vaddr = %16llx\n",
symbol, vaddr);
+ fclose(fp);
return vaddr;
}
}
dbgprintf("Cannot get kernel %s symbol address\n", symbol);
+ fclose(fp);
return 0;
}
--
2.27.0
More information about the kexec
mailing list