From: Ye Liu Use a local variable to avoid the repeated casts and compare the addresses directly instead of relying on unsigned subtraction, which can underflow. No functional change. Signed-off-by: Ye Liu --- mm/vmalloc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 66206de44267..7eec038b8990 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -5661,14 +5661,15 @@ static void __init vmap_init_free_space(void) * |<--------------------------------->| */ for (busy = vmlist; busy; busy = busy->next) { - if ((unsigned long) busy->addr - vmap_start > 0) - vmap_insert_free_area(vmap_start, - (unsigned long) busy->addr); + unsigned long addr = (unsigned long) busy->addr; - vmap_start = (unsigned long) busy->addr + busy->size; + if (addr > vmap_start) + vmap_insert_free_area(vmap_start, addr); + + vmap_start = addr + busy->size; } - if (vmap_end - vmap_start > 0) + if (vmap_start < vmap_end) vmap_insert_free_area(vmap_start, vmap_end); } -- 2.25.1