Skip to contentSkip to conversation

mm/vmalloc: replace BUG_ON to WARN_ON

PATCH New Hyunmin Lee 1 participant 1 message Jan 28, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mm/vmalloc: replace BUG_ON to WARN_ON

As per the coding standards, in the event of an abnormal condition that should not occur under normal circumstances, the kernel should attempt recovery and proceed with execution, rather than halting the machine. Specifically, in the alloc_vmap_area() function, use WARN_ON() and fail the request instead of using BUG_ON() to halt the machine.

---
 mm/vmalloc.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
mm/vmalloc.c +8 -3
index 74afa2208558..9f9dba3132c5 100644
@@ -1587,9 +1587,14 @@ static struct vmap_area *alloc_vmap_area(unsigned long size,
 	int purged = 0;
 	int ret;
 
-	BUG_ON(!size);
-	BUG_ON(offset_in_page(size));
-	BUG_ON(!is_power_of_2(align));
+	if (WARN_ON(!size))
+		return ERR_PTR(-EINVAL);
+
+	if (WARN_ON(offset_in_page(size)))
+		return ERR_PTR(-EINVAL);
+
+	if (WARN_ON(!is_power_of_2(align)))
+		return ERR_PTR(-EINVAL);
 
 	if (unlikely(!vmap_initialized))
 		return ERR_PTR(-EBUSY);
Signature · 1 line
2.25.1