Skip to content

Commit b063e37

Browse files
amitdanielkachhaptorvalds
authored andcommitted
mm/memory.c: avoid unnecessary kernel/user pointer conversion
Annotating a pointer from __user to kernel and then back again might confuse sparse. In copy_huge_page_from_user() it can be avoided by removing the intermediate variable since it is never used. Link: https://lkml.kernel.org/r/20210914150820.19326-1-amit.kachhap@arm.com Signed-off-by: Amit Daniel Kachhap <amit.kachhap@arm.com> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Vincenzo Frascino <Vincenzo.Frascino@arm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent f1dc0db commit b063e37

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

mm/memory.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5421,7 +5421,6 @@ long copy_huge_page_from_user(struct page *dst_page,
54215421
unsigned int pages_per_huge_page,
54225422
bool allow_pagefault)
54235423
{
5424-
void *src = (void *)usr_src;
54255424
void *page_kaddr;
54265425
unsigned long i, rc = 0;
54275426
unsigned long ret_val = pages_per_huge_page * PAGE_SIZE;
@@ -5434,8 +5433,7 @@ long copy_huge_page_from_user(struct page *dst_page,
54345433
else
54355434
page_kaddr = kmap_atomic(subpage);
54365435
rc = copy_from_user(page_kaddr,
5437-
(const void __user *)(src + i * PAGE_SIZE),
5438-
PAGE_SIZE);
5436+
usr_src + i * PAGE_SIZE, PAGE_SIZE);
54395437
if (allow_pagefault)
54405438
kunmap(subpage);
54415439
else

0 commit comments

Comments
 (0)