]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
fs/proc/vmcore: factor out freeing a list of vmcore ranges
authorDavid Hildenbrand <david@redhat.com>
Wed, 4 Dec 2024 12:54:38 +0000 (13:54 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Mon, 27 Jan 2025 14:39:16 +0000 (09:39 -0500)
Let's factor it out into include/linux/crash_dump.h, from where we can
use it also outside of vmcore.c later.

Acked-by: Baoquan He <bhe@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20241204125444.1734652-8-david@redhat.com>
Acked-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
fs/proc/vmcore.c
include/linux/crash_dump.h

index 7ad94fa7a2aff5ed35fd91d3b9c534c31a5a8de9..6632d4bc4b05362d0d9ad501c78c42d89e5678c3 100644 (file)
@@ -1592,14 +1592,7 @@ void vmcore_cleanup(void)
                proc_vmcore = NULL;
        }
 
-       /* clear the vmcore list. */
-       while (!list_empty(&vmcore_list)) {
-               struct vmcore_range *m;
-
-               m = list_first_entry(&vmcore_list, struct vmcore_range, list);
-               list_del(&m->list);
-               kfree(m);
-       }
+       vmcore_free_ranges(&vmcore_list);
        free_elfcorebuf();
 
        /* clear vmcore device dump list */
index 9717912ce4d1d58d251cbbbca8ec734bd254c658..5d61c7454fd600948b9ba91150da6f2b429701b1 100644 (file)
@@ -135,6 +135,17 @@ static inline int vmcore_alloc_add_range(struct list_head *list,
        return 0;
 }
 
+/* Free a list of vmcore ranges. */
+static inline void vmcore_free_ranges(struct list_head *list)
+{
+       struct vmcore_range *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 */