linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/mmap.c: use IS_ERR_VALUE to check return value of get_unmapped_area
@ 2019-10-10  3:31 Gaowei Pu
  2019-10-12  2:19 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Gaowei Pu @ 2019-10-10  3:31 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Vlastimil Babka, linux-mm

get_unmapped_area already cover the offset_in_page() check and returned
with error ptr. So replace offset_in_page() with IS_ERR_VALUE().

Signed-off-by: Gaowei Pu <pugaowei@gmail.com>
---
 mm/mmap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index 7e8c3e8ae75f..66cd88b2abb7 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -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);
-- 
2.22.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm/mmap.c: use IS_ERR_VALUE to check return value of get_unmapped_area
  2019-10-10  3:31 [PATCH] mm/mmap.c: use IS_ERR_VALUE to check return value of get_unmapped_area Gaowei Pu
@ 2019-10-12  2:19 ` Andrew Morton
  2019-10-12  9:41   ` gaowei Pu
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2019-10-12  2:19 UTC (permalink / raw)
  To: Gaowei Pu; +Cc: Vlastimil Babka, linux-mm

On Thu, 10 Oct 2019 11:31:17 +0800 Gaowei Pu <pugaowei@gmail.com> wrote:

> get_unmapped_area already cover the offset_in_page() check and returned
> with error ptr. So replace offset_in_page() with IS_ERR_VALUE().
> 
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -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))



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm/mmap.c: use IS_ERR_VALUE to check return value of get_unmapped_area
  2019-10-12  2:19 ` Andrew Morton
@ 2019-10-12  9:41   ` gaowei Pu
  0 siblings, 0 replies; 3+ messages in thread
From: gaowei Pu @ 2019-10-12  9:41 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Vlastimil Babka, linux-mm

[-- Attachment #1: Type: text/plain, Size: 678 bytes --]

Andrew Morton <akpm@linux-foundation.org> 于2019年10月12日周六 上午10:19写道:

>
> ./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))
>
>
Thanks for your review.
I will send a v2.

[-- Attachment #2: Type: text/html, Size: 1108 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-10-12  9:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-10  3:31 [PATCH] mm/mmap.c: use IS_ERR_VALUE to check return value of get_unmapped_area Gaowei Pu
2019-10-12  2:19 ` Andrew Morton
2019-10-12  9:41   ` gaowei Pu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).