Skip to content

Commit ff9b7e0

Browse files
tobluxakpm00
authored andcommitted
mm/kfence: use str_write_read() helper in get_access_type()
Remove hard-coded strings by using the str_write_read() helper function. Link: https://lkml.kernel.org/r/20250115155511.954535-2-thorsten.blum@linux.dev Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Suggested-by: Anshuman Khandual <anshuman.khandual@arm.com> Reviewed-by: Marco Elver <elver@google.com> Cc: Alexander Potapenko <glider@google.com> Cc: Anshuman Khandual <anshuman.khandual@arm.com> Cc: Dmitriy Vyukov <dvyukov@google.com> Cc: Thorsten Blum <thorsten.blum@linux.dev> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 7882d8f commit ff9b7e0

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

mm/kfence/kfence_test.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/slab.h>
2121
#include <linux/spinlock.h>
2222
#include <linux/string.h>
23+
#include <linux/string_choices.h>
2324
#include <linux/tracepoint.h>
2425
#include <trace/events/printk.h>
2526

@@ -88,7 +89,7 @@ struct expect_report {
8889

8990
static const char *get_access_type(const struct expect_report *r)
9091
{
91-
return r->is_write ? "write" : "read";
92+
return str_write_read(r->is_write);
9293
}
9394

9495
/* Check observed report matches information in @r. */

mm/kfence/report.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/sprintf.h>
1717
#include <linux/stacktrace.h>
1818
#include <linux/string.h>
19+
#include <linux/string_choices.h>
1920
#include <linux/sched/clock.h>
2021
#include <trace/events/error_report.h>
2122

@@ -184,7 +185,7 @@ static void print_diff_canary(unsigned long address, size_t bytes_to_show,
184185

185186
static const char *get_access_type(bool is_write)
186187
{
187-
return is_write ? "write" : "read";
188+
return str_write_read(is_write);
188189
}
189190

190191
void kfence_report_error(unsigned long address, bool is_write, struct pt_regs *regs,

0 commit comments

Comments
 (0)