Skip to content

Commit

Permalink
mm/kfence: use str_write_read() helper in get_access_type()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
toblux authored and akpm00 committed Jan 26, 2025
1 parent 7882d8f commit ff9b7e0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion mm/kfence/kfence_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/string.h>
#include <linux/string_choices.h>
#include <linux/tracepoint.h>
#include <trace/events/printk.h>

Expand Down Expand Up @@ -88,7 +89,7 @@ struct expect_report {

static const char *get_access_type(const struct expect_report *r)
{
return r->is_write ? "write" : "read";
return str_write_read(r->is_write);
}

/* Check observed report matches information in @r. */
Expand Down
3 changes: 2 additions & 1 deletion mm/kfence/report.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/sprintf.h>
#include <linux/stacktrace.h>
#include <linux/string.h>
#include <linux/string_choices.h>
#include <linux/sched/clock.h>
#include <trace/events/error_report.h>

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

static const char *get_access_type(bool is_write)
{
return is_write ? "write" : "read";
return str_write_read(is_write);
}

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

0 comments on commit ff9b7e0

Please sign in to comment.