mm/mmap.c: use IS_ERR_VALUE to check return value of get_unmapped_area
Subsystems (2)
PATCH 1/1 mm/mmap.c: use IS_ERR_VALUE to check return value of get_unmapped_area
get_unmapped_area already cover the offset_in_page() check and returned with error ptr. So replace offset_in_page() with IS_ERR_VALUE().
--- mm/mmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/mmap.c +2 -2
@@ -1430,7 +1430,7 @@ unsigned long do_mmap(struct file *file, unsigned long addr,* that it represents a valid section of the address space. */ addr =get_unmapped_area (file, addr, len, pgoff, flags); -if (offset_in_page (addr)) +if (IS_ERR_VALUE (addr))return addr;if (flags &MAP_FIXED_NOREPLACE ) {
@@ -2997,7 +2997,7 @@ static int do_brk_flags(unsigned long addr, unsigned long len, unsigned long fla flags |=VM_DATA_DEFAULT_FLAGS |VM_ACCOUNT | mm->def_flags; error =get_unmapped_area (NULL , addr, len,0 ,MAP_FIXED ); -if (offset_in_page (error)) +if (IS_ERR_VALUE (error))return error; error =mlock_future_check (mm, mm->def_flags, len);
Signature · 1 line
2.22.0
Andrew Morton
maintainerQuoted 6 lines · On Thu, 10 Oct 2019 11:31:17 +0800 Gaowei Pu <[email protected]> wrote:
get_unmapped_areaalready cover theoffset_in_page()check and returned with error ptr. So replaceoffset_in_page()withIS_ERR_VALUE().
mm/mmap.c static int do_brk_flags(unsigned long addr, unsigned long len, unsigned long fla · line 3003
Quoted 8 lines
mm/mmap.c +1
-1@@ -2997,7 +2997,7 @@ static int do_brk_flags(unsigned long addr, unsigned long len, unsigned long fla flags |=VM_DATA_DEFAULT_FLAGS |VM_ACCOUNT | mm->def_flags; error =get_unmapped_area (NULL , addr, len,0 ,MAP_FIXED ); -if (offset_in_page (error)) +if (IS_ERR_VALUE (error))return error; error =mlock_future_check (mm, mm->def_flags, len);
./include/linux/err.h:22:49: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
#define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO)
^
./include/linux/compiler.h:78:42: note: in definition of macro unlikely
# define unlikely(x) __builtin_expect(!!(x), 0)
^
mm/mmap.c:3006:6: note: in expansion of macro IS_ERR_VALUE
if (IS_ERR_VALUE(error))Quoted 5 lines · Andrew Morton <[email protected]> 于2019年10月12日周六 上午10:19写道:
./include/linux/err.h:22:49: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
#defineIS_ERR_VALUE(x)unlikely((unsigned long)(void *)(x) >= (unsigned
long)-MAX_ERRNO)
Quoted 8 lines
^
./include/linux/compiler.h:78:42: note: in definition of macro unlikely
# define unlikely(x) __builtin_expect(!!(x), 0)
^
mm/mmap.c:3006:6: note: in expansion of macro IS_ERR_VALUE
if (IS_ERR_VALUE(error))Thanks for your review.
I will send a v2.