[GIT PULL] tracing: A couple more minor fixes

From: Steven Rostedt
Date: Fri Apr 07 2023 - 16:35:49 EST



Linus,

Some more tracing fixes for 6.3:

- Reset direct->addr back to its original value on error in updating
the direct trampoline code.

- Make lastcmd_mutex static.


Please pull the latest trace-v6.3-rc5-2 tree, which can be found at:


git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
trace-v6.3-rc5-2

Tag SHA1: 6eaf0925d5343e35303a4e3dc0082f889c9d8d78
Head SHA1: 31c683967174b487939efaf65e41f5ff1404e141


Steven Rostedt (Google) (1):
tracing/synthetic: Make lastcmd_mutex static

Zheng Yejian (1):
ftrace: Fix issue that 'direct->addr' not restored in modify_ftrace_direct()

----
kernel/trace/ftrace.c | 15 +++++++++------
kernel/trace/trace_events_synth.c | 2 +-
2 files changed, 10 insertions(+), 7 deletions(-)
---------------------------
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 0feea145bb29..c67bcc89a771 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -5667,12 +5667,15 @@ int modify_ftrace_direct(unsigned long ip,
ret = 0;
}

- if (unlikely(ret && new_direct)) {
- direct->count++;
- list_del_rcu(&new_direct->next);
- synchronize_rcu_tasks();
- kfree(new_direct);
- ftrace_direct_func_count--;
+ if (ret) {
+ direct->addr = old_addr;
+ if (unlikely(new_direct)) {
+ direct->count++;
+ list_del_rcu(&new_direct->next);
+ synchronize_rcu_tasks();
+ kfree(new_direct);
+ ftrace_direct_func_count--;
+ }
}

out_unlock:
diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c
index f0ff730125bf..d6a70aff2410 100644
--- a/kernel/trace/trace_events_synth.c
+++ b/kernel/trace/trace_events_synth.c
@@ -44,7 +44,7 @@ enum { ERRORS };

static const char *err_text[] = { ERRORS };

-DEFINE_MUTEX(lastcmd_mutex);
+static DEFINE_MUTEX(lastcmd_mutex);
static char *last_cmd;

static int errpos(const char *str)