It is encouraged to warn and return rather than use BUG_ON() when the condition can be recovered from in ways that are more graceful than halting the whole system.
Signed-off-by: Mathieu Desnoyers <[email protected]> Suggested-by: Steven Rostedt <[email protected]> CC: Sergey Senozhatsky <[email protected]> CC: Matthew Wilcox <[email protected]> CC: "Paul E. McKenney" <[email protected]> CC: Peter Zijlstra <[email protected]> CC: Paul Turner <[email protected]> CC: Thomas Gleixner <[email protected]> CC: Andy Lutomirski <[email protected]> CC: Andi Kleen <[email protected]> CC: Dave Watson <[email protected]> CC: Chris Lameter <[email protected]> CC: Ingo Molnar <[email protected]> CC: "H. Peter Anvin" <[email protected]> CC: Ben Maurer <[email protected]> CC: Steven Rostedt <[email protected]> CC: Josh Triplett <[email protected]> CC: Linus Torvalds <[email protected]> CC: Andrew Morton <[email protected]> CC: Russell King <[email protected]> CC: Catalin Marinas <[email protected]> CC: Will Deacon <[email protected]> CC: Michael Kerrisk <[email protected]> CC: Boqun Feng <[email protected]> --- mm/vmalloc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index a728fc492557..a236bac872f0 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1123,10 +1123,11 @@ void vm_unmap_ram(const void *mem, unsigned int count) struct vmap_area *va; might_sleep(); - BUG_ON(!addr); - BUG_ON(addr < VMALLOC_START); - BUG_ON(addr > VMALLOC_END); - BUG_ON(!PAGE_ALIGNED(addr)); + if (WARN_ON(!addr) || + WARN_ON(addr < VMALLOC_START) || + WARN_ON(addr > VMALLOC_END) || + WARN_ON(!PAGE_ALIGNED(addr))) + return; if (likely(count <= VMAP_MAX_ALLOC)) { debug_check_no_locks_freed(mem, size); @@ -1135,7 +1136,8 @@ void vm_unmap_ram(const void *mem, unsigned int count) } va = find_vmap_area(addr); - BUG_ON(!va); + if (WARN_ON(!va)) + return; debug_check_no_locks_freed((void *)va->va_start, (va->va_end - va->va_start)); free_unmap_vmap_area(va); -- 2.11.0

