From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753557AbbFSXVA (ORCPT ); Fri, 19 Jun 2015 19:21:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42642 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753364AbbFSXUc (ORCPT ); Fri, 19 Jun 2015 19:20:32 -0400 Date: Sat, 20 Jun 2015 01:19:21 +0200 From: Oleg Nesterov To: Andrew Morton Cc: Al Viro , Benjamin LaHaise , Hugh Dickins , Jeff Moyer , Kirill Shutemov , linux-kernel@vger.kernel.org Subject: [PATCH 4/4] mremap: simplify the "overlap" check in mremap_to() Message-ID: <20150619231921.GA25894@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150619231854.GA25858@redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Minor, but this check is overcomplicated. Two half-intervals do NOT overlap if END1 <= START2 || END2 <= START1, mremap_to() just needs to negate this check. Signed-off-by: Oleg Nesterov --- mm/mremap.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-) diff --git a/mm/mremap.c b/mm/mremap.c index 2416721..ed1b13a 100644 --- a/mm/mremap.c +++ b/mm/mremap.c @@ -406,10 +406,7 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len, /* Check if the location we're moving into overlaps the * old location at all, and fail if it does. */ - if ((new_addr <= addr) && (new_addr+new_len) > addr) - goto out; - - if ((addr <= new_addr) && (addr+old_len) > new_addr) + if (addr + old_len > new_addr && new_addr + new_len > addr) goto out; ret = do_munmap(mm, new_addr, new_len); -- 1.5.5.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in Please read the FAQ at http://www.tux.org/lkml/