free_early_partial() should permit start == end
PATCH 1/1 free_early_partial() should permit start == end
The per-CPU allocator, when using atom_size == PAGE_SIZE, may call free_area_init_partial() this way.
--- kernel/early_res.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/early_res.c +2 -2
@@ -335,10 +335,10 @@ void __init free_early_partial(u64 start try_next: i =find_overlapped_early (start, end); -if (i >= max_early_res) + r = &early_res[i]; +if (i >= max_early_res || !r->end)return ; - r = &early_res[i];/* hole ? */ if (r->end >= end && r->start <= start) {drop_range_partial (i, start, end);
Quoted 16 lines · Jan Beulich
The per-CPU allocator, when using
atom_size==PAGE_SIZE, may callfree_area_init_partial()this way.Signed-off-by Jan Beulich <[email protected]>--- kernel/early_res.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)kernel/early_res.c +0
-0@@ -335,10 +335,10 @@ void __init free_early_partial(u64 start try_next:
kernel/early_res.c void __init free_early_partial(u64 start · line 344
Quoted 10 lines
kernel/early_res.c +2
-2i =find_overlapped_early (start, end); -if (i >= max_early_res) + r = &early_res[i]; +if (i >= max_early_res || !r->end)return ; - r = &early_res[i];/* hole ? */ if (r->end >= end && r->start <= start) {drop_range_partial (i, start, end);
can you check if this patch work for you?
Thanks
Yinghai Lu
Subject: [PATCH -v6] x86: do not free zero sized per cpu areas
From: Ian Campbell <[email protected]>
This avoids an infinite loop in free_early_partial().
Add a warning to free_early_partial to catch future problems.
-v5: put back start > end back into WARN_ONCE()
-v6: use one line for if according to linus
--- kernel/early_res.c | 6 ++++++ 1 file changed, 6 insertions(+)
kernel/early_res.c +6 -0
@@ -333,6 +333,12 @@ void __init free_early_partial(u64 startstruct early_res *r;int i; +if (start == end) +return ; + +if (WARN_ONCE (start > end,"free_early_partial: wrong range [%#llx, %#llx]\n" , start, end)) +return ; + try_next: i =find_overlapped_early (start, end);if (i >= max_early_res)
Quoted 2 lines
Quoted 1 line
Quoted 1 line
Yinghai Lu <[email protected]> 26.03.10 21:39 >>>
can you check if this patch work for you?
I'm sure it works, too. But I find it less clean to add special case handling instead of just getting the original code right.
Jan