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 <mathieu.desnoyers@xxxxxxxxxxxx> Suggested-by: Steven Rostedt <rostedt@xxxxxxxxxxx> CC: Sergey Senozhatsky <sergey.senozhatsky@xxxxxxxxx> CC: Matthew Wilcox <mawilcox@xxxxxxxxxxxxx> CC: "Paul E. McKenney" <paulmck@xxxxxxxxxxxxxxxxxx> CC: Peter Zijlstra <peterz@xxxxxxxxxxxxx> CC: Paul Turner <pjt@xxxxxxxxxx> CC: Thomas Gleixner <tglx@xxxxxxxxxxxxx> CC: Andy Lutomirski <luto@xxxxxxxxxxxxxx> CC: Andi Kleen <andi@xxxxxxxxxxxxxx> CC: Dave Watson <davejwatson@xxxxxx> CC: Chris Lameter <cl@xxxxxxxxx> CC: Ingo Molnar <mingo@xxxxxxxxxx> CC: "H. Peter Anvin" <hpa@xxxxxxxxx> CC: Ben Maurer <bmaurer@xxxxxx> CC: Steven Rostedt <rostedt@xxxxxxxxxxx> CC: Josh Triplett <josh@xxxxxxxxxxxxxxxx> CC: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> CC: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> CC: Russell King <linux@xxxxxxxxxxxxxxxx> CC: Catalin Marinas <catalin.marinas@xxxxxxx> CC: Will Deacon <will.deacon@xxxxxxx> CC: Michael Kerrisk <mtk.manpages@xxxxxxxxx> CC: Boqun Feng <boqun.feng@xxxxxxxxx> --- 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