From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
To: Wang Xiaoqiang <wangxq10@lzu.edu.cn>
Cc: Oleg Nesterov <oleg@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: [PATCH] mm/mmap.c: remove redundant check "if (length < info->length)"
Date: Fri, 8 Jan 2016 08:11:27 +0000 [thread overview]
Message-ID: <20160108081125.GA11868@hori1.linux.bs1.fc.nec.co.jp> (raw)
In-Reply-To: <20160107165923.77fea9a3@debian>
On Thu, Jan 07, 2016 at 04:59:23PM +0800, Wang Xiaoqiang wrote:
> Hi, all,
>
> since the code:
>
> length = info->length + info->align_mask
>
> and all variables above are "unsigned long" type,
> so there must be "length >= info->length".
I think that if info->align_mask is "very large" as an unsigned long value
and the sum of these 2 overflows, length can become smaller than info->length,
so we seem to need the check.
But why returning -ENOMEM? Isn't it worth VM_BUG_ON()?
Thanks,
Naoya Horiguchi
>
> Signed-off-by: Wang Xiaoqiang <wangxq10@lzu.edu.cn>
> ---
> mm/mmap.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/mm/mmap.c b/mm/mmap.c
> index 2ce04a6..99fc461 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -1716,8 +1716,6 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
>
> /* Adjust search length to account for worst case alignment overhead */
> length = info->length + info->align_mask;
> - if (length < info->length)
> - return -ENOMEM;
>
> /* Adjust search limits by the desired length */
> if (info->high_limit < length)
> --
> 2.1.4
>
> thanks,
> Wang Xiaoqiang
>
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
parent reply other threads:[~2016-01-08 8:15 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20160107165923.77fea9a3@debian>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160108081125.GA11868@hori1.linux.bs1.fc.nec.co.jp \
--to=n-horiguchi@ah.jp.nec.com \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=oleg@redhat.com \
--cc=wangxq10@lzu.edu.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox