Skip to content

Commit e29e9ac

Browse files
davidhildenbrandmstsirkin
authored andcommitted
fs/proc/vmcore: factor out freeing a list of vmcore ranges
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 <[email protected]> Signed-off-by: David Hildenbrand <[email protected]> Message-Id: <[email protected]> Acked-by: Andrew Morton <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent e017b1f commit e29e9ac

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

fs/proc/vmcore.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,14 +1592,7 @@ void vmcore_cleanup(void)
15921592
proc_vmcore = NULL;
15931593
}
15941594

1595-
/* clear the vmcore list. */
1596-
while (!list_empty(&vmcore_list)) {
1597-
struct vmcore_range *m;
1598-
1599-
m = list_first_entry(&vmcore_list, struct vmcore_range, list);
1600-
list_del(&m->list);
1601-
kfree(m);
1602-
}
1595+
vmcore_free_ranges(&vmcore_list);
16031596
free_elfcorebuf();
16041597

16051598
/* clear vmcore device dump list */

include/linux/crash_dump.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,17 @@ static inline int vmcore_alloc_add_range(struct list_head *list,
135135
return 0;
136136
}
137137

138+
/* Free a list of vmcore ranges. */
139+
static inline void vmcore_free_ranges(struct list_head *list)
140+
{
141+
struct vmcore_range *m, *tmp;
142+
143+
list_for_each_entry_safe(m, tmp, list, list) {
144+
list_del(&m->list);
145+
kfree(m);
146+
}
147+
}
148+
138149
#else /* !CONFIG_CRASH_DUMP */
139150
static inline bool is_kdump_kernel(void) { return false; }
140151
#endif /* CONFIG_CRASH_DUMP */

0 commit comments

Comments
 (0)