[PATCH] fix comparison of unsigned expression < 0
From: Haibo Li
Date: Tue Nov 28 2023 - 02:56:03 EST
Kernel test robot reported:
'''
mm/kasan/report.c:637 kasan_non_canonical_hook() warn:
unsigned 'addr' is never less than zero.
'''
The KASAN_SHADOW_OFFSET is 0 on loongarch64.
To fix it,check the KASAN_SHADOW_OFFSET before do comparison.
Signed-off-by: Haibo Li <haibo.li@xxxxxxxxxxxx>
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Closes: https://lore.kernel.org/oe-kbuild-all/
202311270743.3oTCwYPd-lkp@xxxxxxxxx/
---
mm/kasan/report.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/kasan/report.c b/mm/kasan/report.c
index e77facb62900..dafec2df0268 100644
--- a/mm/kasan/report.c
+++ b/mm/kasan/report.c
@@ -634,10 +634,10 @@ void kasan_non_canonical_hook(unsigned long addr)
{
unsigned long orig_addr;
const char *bug_type;
-
+#if KASAN_SHADOW_OFFSET > 0
if (addr < KASAN_SHADOW_OFFSET)
return;
-
+#endif
orig_addr = (addr - KASAN_SHADOW_OFFSET) << KASAN_SHADOW_SCALE_SHIFT;
/*
* For faults near the shadow address for NULL, we can be fairly certain
--
2.18.0