summaryrefslogtreecommitdiffstats
path: root/mm/kasan
diff options
context:
space:
mode:
authorAndrey Konovalov <andreyknvl@google.com>2022-03-24 18:12:49 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2022-03-24 19:06:49 -0700
commitb3bb1d700e51128e9ff818f76b930403b1ed2c7d (patch)
tree4e97c3cbae0b4020d1d1f09111944a881ca2bb1a /mm/kasan
parentb91328002d266da3f53703f753b3a2af0dc9b9c1 (diff)
downloadlinux-stable-b3bb1d700e51128e9ff818f76b930403b1ed2c7d.tar.gz
linux-stable-b3bb1d700e51128e9ff818f76b930403b1ed2c7d.tar.bz2
linux-stable-b3bb1d700e51128e9ff818f76b930403b1ed2c7d.zip
kasan: restructure kasan_report
Restructure kasan_report() to make reviewing the subsequent patches easier. Link: https://lkml.kernel.org/r/ca28042889858b8cc4724d3d4378387f90d7a59d.1646237226.git.andreyknvl@google.com Signed-off-by: Andrey Konovalov <andreyknvl@google.com> Cc: Alexander Potapenko <glider@google.com> Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Marco Elver <elver@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/kasan')
-rw-r--r--mm/kasan/report.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/mm/kasan/report.c b/mm/kasan/report.c
index a0d4a9d3f933..41c7966451e3 100644
--- a/mm/kasan/report.c
+++ b/mm/kasan/report.c
@@ -457,15 +457,18 @@ static void __kasan_report(void *addr, size_t size, bool is_write,
bool kasan_report(unsigned long addr, size_t size, bool is_write,
unsigned long ip)
{
- unsigned long flags = user_access_save();
- bool ret = false;
+ unsigned long ua_flags = user_access_save();
+ bool ret = true;
- if (likely(report_enabled())) {
- __kasan_report((void *)addr, size, is_write, ip);
- ret = true;
+ if (unlikely(!report_enabled())) {
+ ret = false;
+ goto out;
}
- user_access_restore(flags);
+ __kasan_report((void *)addr, size, is_write, ip);
+
+out:
+ user_access_restore(ua_flags);
return ret;
}