[v3,3/3] mm: vmalloc: Replace BUG_ON() by WARN_ON_ONCE()

Message ID 20221222190022.134380-3-urezki@gmail.com
State New
Headers
Series [v3,1/3] mm: vmalloc: Avoid calling __find_vmap_area() twice in __vunmap() |

Commit Message

Uladzislau Rezki Dec. 22, 2022, 7 p.m. UTC
  Currently a vm_unmap_ram() functions triggers a BUG() if an area
is not found. Replace it by the WARN_ON_ONCE() error message and
keep machine alive instead of stopping it.

The worst case is a memory leaking.

Reviewed-by: Lorenzo Stoakes <lstoakes@gmail.com>
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
 mm/vmalloc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Comments

Christoph Hellwig Dec. 23, 2022, 8:21 a.m. UTC | #1
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
  

Patch

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 70e5000b9d68..09a9b93b32ca 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2253,7 +2253,9 @@  void vm_unmap_ram(const void *mem, unsigned int count)
 	}
 
 	va = find_unlink_vmap_area(addr);
-	BUG_ON(!va);
+	if (WARN_ON_ONCE(!va))
+		return;
+
 	debug_check_no_locks_freed((void *)va->va_start,
 				    (va->va_end - va->va_start));
 	free_unmap_vmap_area(va);