@@ -1568,14 +1568,7 @@ void vmcore_cleanup(void)
proc_vmcore = NULL;
}
- /* clear the vmcore list. */
- while (!list_empty(&vmcore_list)) {
- struct vmcore_mem_node *m;
-
- m = list_first_entry(&vmcore_list, struct vmcore_mem_node, list);
- list_del(&m->list);
- kfree(m);
- }
+ vmcore_free_mem_nodes(&vmcore_list);
free_elfcorebuf();
/* clear vmcore device dump list */
@@ -135,6 +135,17 @@ static inline int vmcore_alloc_add_mem_node(struct list_head *list,
return 0;
}
+/* Free a list of vmcore memory nodes. */
+static inline void vmcore_free_mem_nodes(struct list_head *list)
+{
+ struct vmcore_mem_node *m, *tmp;
+
+ list_for_each_entry_safe(m, tmp, list, list) {
+ list_del(&m->list);
+ kfree(m);
+ }
+}
+
#else /* !CONFIG_CRASH_DUMP */
static inline bool is_kdump_kernel(void) { return false; }
#endif /* CONFIG_CRASH_DUMP */
Let's factor it out into include/linux/crash_dump.h, from where we can use it also outside of vmcore.c later. Signed-off-by: David Hildenbrand <david@redhat.com> --- fs/proc/vmcore.c | 9 +-------- include/linux/crash_dump.h | 11 +++++++++++ 2 files changed, 12 insertions(+), 8 deletions(-)