Skip to content

Commit 3c9fe8b

Browse files
MiaoheLinakpm00
authored andcommitted
mm/mremap: avoid unneeded do_munmap call
When old_len == new_len, do_munmap will return -EINVAL due to len == 0. This errno will be simply ignored because of old_len != new_len check. So it is unnecessary to call do_munmap when old_len == new_len because nothing is actually done. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Miaohe Lin <[email protected]> Acked-by: David Hildenbrand <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent f433195 commit 3c9fe8b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mm/mremap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,9 +820,9 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
820820
goto out;
821821
}
822822

823-
if (old_len >= new_len) {
823+
if (old_len > new_len) {
824824
ret = do_munmap(mm, addr+new_len, old_len - new_len, uf_unmap);
825-
if (ret && old_len != new_len)
825+
if (ret)
826826
goto out;
827827
old_len = new_len;
828828
}

0 commit comments

Comments
 (0)