* [PATCH] mm/memory: Avoid unnecessary kernel/user pointer conversion
@ 2021-09-14 15:08 Amit Daniel Kachhap
2021-09-15 10:40 ` Kirill A. Shutemov
0 siblings, 1 reply; 2+ messages in thread
From: Amit Daniel Kachhap @ 2021-09-14 15:08 UTC (permalink / raw)
To: linux-mm
Cc: linux-kernel, Vincenzo Frascino, Amit Daniel Kachhap, Andrew Morton
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.
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Amit Daniel Kachhap <amit.kachhap@arm.com>
---
mm/memory.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/mm/memory.c b/mm/memory.c
index 25fc46e87214..90970d19b7dd 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -5411,7 +5411,6 @@ long copy_huge_page_from_user(struct page *dst_page,
unsigned int pages_per_huge_page,
bool allow_pagefault)
{
- void *src = (void *)usr_src;
void *page_kaddr;
unsigned long i, rc = 0;
unsigned long ret_val = pages_per_huge_page * PAGE_SIZE;
@@ -5424,8 +5423,7 @@ long copy_huge_page_from_user(struct page *dst_page,
else
page_kaddr = kmap_atomic(subpage);
rc = copy_from_user(page_kaddr,
- (const void __user *)(src + i * PAGE_SIZE),
- PAGE_SIZE);
+ usr_src + i * PAGE_SIZE, PAGE_SIZE);
if (allow_pagefault)
kunmap(subpage);
else
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/memory: Avoid unnecessary kernel/user pointer conversion
2021-09-14 15:08 [PATCH] mm/memory: Avoid unnecessary kernel/user pointer conversion Amit Daniel Kachhap
@ 2021-09-15 10:40 ` Kirill A. Shutemov
0 siblings, 0 replies; 2+ messages in thread
From: Kirill A. Shutemov @ 2021-09-15 10:40 UTC (permalink / raw)
To: Amit Daniel Kachhap
Cc: linux-mm, linux-kernel, Vincenzo Frascino, Andrew Morton
On Tue, Sep 14, 2021 at 08:38:20PM +0530, Amit Daniel Kachhap wrote:
> 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.
>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Amit Daniel Kachhap <amit.kachhap@arm.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
--
Kirill A. Shutemov
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-09-15 10:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-14 15:08 [PATCH] mm/memory: Avoid unnecessary kernel/user pointer conversion Amit Daniel Kachhap
2021-09-15 10:40 ` Kirill A. Shutemov
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).