lkml.org 
[lkml]   [2024]   [Apr]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH v2] mm/vmalloc: fix return value of vb_alloc if size is 0.
Date
From: "Hailong.Liu" <hailong.liu@oppo.com>

vm_map_ram check return value of vb_alloc by IS_ERR. if
vm_map_ram(page, 0, 0) , vb_alloc(0, GFP_KERNEL) would return NULL
which cause kernel panic by vmap_pages_range_noflush。fix this by
return ERR_PTR(-EINVAL) if size is 0.

Signed-off-by: Hailong.Liu <hailong.liu@oppo.com>
---
Changes since v1 [1]:
- Return ERR_PTR(-EINVAL) or not check IS_ERR_OR_NULL

BTW, Barry suggests me that if count is 0, return directly, in my
opinion, change return value is more resonable.

[1] https://lore.kernel.org/all/84d7cd03-1cf8-401a-8edf-2524db0bd6d5@oppo.com/

mm/vmalloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index a3fedb3ee0db..c430a999805b 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2173,7 +2173,7 @@ static void *vb_alloc(unsigned long size, gfp_t gfp_mask)
* get_order(0) returns funny result. Just warn and terminate
* early.
*/
- return NULL;
+ return ERR_PTR(-EINVAL);
}
order = get_order(size);

--
2.34.1

\
 
 \ /
  Last update: 2024-05-27 16:46    [W:0.064 / U:0.420 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site