public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: Fixes warning: cast removes address space '__user' of expression in uaccess_64.h
@ 2023-11-16 17:38 Dipendra Khadka
  2023-11-17 15:19 ` Dave Hansen
  0 siblings, 1 reply; 6+ messages in thread
From: Dipendra Khadka @ 2023-11-16 17:38 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen, x86, hpa
  Cc: Dipendra Khadka, mjguzik, ira.weiny, linux-kernel

Sparse has identified a warning as follows:

./arch/x86/include/asm/uaccess_64.h:88:24: warning: cast removes address space '__user' of expression.

Since the valid_user_address(x) macro implicitly casts the argument
to long and compares the converted value of x to zero, casting ptr
to unsigned long has no functional impact and does not trigger a 
Sparse warning either.

Signed-off-by: Dipendra Khadka <kdipendra88@gmail.com>
---
 arch/x86/include/asm/uaccess_64.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
index f2c02e4469cc..da24d807e101 100644
--- a/arch/x86/include/asm/uaccess_64.h
+++ b/arch/x86/include/asm/uaccess_64.h
@@ -85,7 +85,7 @@ static inline unsigned long __untagged_addr_remote(struct mm_struct *mm,
 static inline bool __access_ok(const void __user *ptr, unsigned long size)
 {
 	if (__builtin_constant_p(size <= PAGE_SIZE) && size <= PAGE_SIZE) {
-		return valid_user_address(ptr);
+		return valid_user_address((unsigned long)ptr);
 	} else {
 		unsigned long sum = size + (unsigned long)ptr;
 		return valid_user_address(sum) && sum >= (unsigned long)ptr;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-01-24  6:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-16 17:38 [PATCH] x86: Fixes warning: cast removes address space '__user' of expression in uaccess_64.h Dipendra Khadka
2023-11-17 15:19 ` Dave Hansen
     [not found]   ` <CAEKBCKNsw60QM=Ay6CH2Kuh-L8YdjVB5yScjG9pTZUXcBrsf5w@mail.gmail.com>
2023-11-17 19:31     ` Dipendra Khadka
2023-11-17 19:47       ` Dipendra Khadka
2023-12-23  9:07         ` Dipendra Khadka
2024-01-24  6:08   ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox