Skip to contentSkip to conversation

kexec:Add some necessary fclose() calls

PATCH Applied Kai Song 2 participants 2 messages Sep 29, 2021 – Oct 5, 2021

Subsystems (2)
lore
Share & tools
lore

Kai Song

author
#0 lore raw

PATCH 1/1 kexec:Add some necessary fclose() calls

fclose should be called before function exits

---
 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(-)
kexec/arch/ppc/fixup_dtb.c +2 -0
index 4524c8c..92a0bfd 100644
@@ -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");
 	}
kexec/arch/ppc64/crashdump-ppc64.c +1 -0
index addd769..91f9521 100644
@@ -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;
 		}
 
kexec/arch/ppc64/kexec-ppc64.c +3 -1
index 4e70b13..5b17740 100644
@@ -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
kexec/symbols.c +2 -0
index e88f7f3..04377ca 100644
@@ -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;
 }
Signature · 7 lines
2.27.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec