* [PATCH] libtracefs: Do not allow tracefs_synth_set_instance() on created synth
@ 2023-05-30 5:47 Steven Rostedt
0 siblings, 0 replies; only message in thread
From: Steven Rostedt @ 2023-05-30 5:47 UTC (permalink / raw)
To: Linux Trace Devel; +Cc: Tzvetomir Stoyanov
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
If tracefs_synth_create() is called on a synthetic event descriptor, do
not let its instance change after that. Currently
tracefs_synth_set_instance() returns success when called on a created
instance, where it has no effect. Make it fail in such cases.
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
src/tracefs-hist.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/tracefs-hist.c b/src/tracefs-hist.c
index 1e3df6c67d7e..ecfce7442176 100644
--- a/src/tracefs-hist.c
+++ b/src/tracefs-hist.c
@@ -748,6 +748,7 @@ struct name_hash {
* @start_parens: Current parenthesis level for start event
* @end_parens: Current parenthesis level for end event
* @new_format: onmatch().trace(synth_event,..) or onmatch().synth_event(...)
+ * @created: Set if tracefs_synth_create() was called on this; cleared on destroy()
*/
struct tracefs_synth {
struct tracefs_instance *instance;
@@ -778,6 +779,7 @@ struct tracefs_synth {
char arg_name[16];
int arg_cnt;
bool new_format;
+ bool created;
};
/*
@@ -2207,7 +2209,7 @@ tracefs_synth_get_start_hist(struct tracefs_synth *synth)
*/
int tracefs_synth_set_instance(struct tracefs_synth *synth, struct tracefs_instance *instance)
{
- if (!synth)
+ if (!synth || synth->created)
return -1;
synth->instance = instance;
return 0;
@@ -2271,6 +2273,8 @@ int tracefs_synth_create(struct tracefs_synth *synth)
if (ret < 0)
goto remove_start_hist;
+ synth->created = true;
+
return 0;
remove_start_hist:
@@ -2334,6 +2338,9 @@ int tracefs_synth_destroy(struct tracefs_synth *synth)
ret = tracefs_dynevent_destroy(synth->dyn_event, true);
+ if (!ret)
+ synth->created = false;
+
return ret ? -1 : 0;
}
--
2.39.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-05-30 5:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-30 5:47 [PATCH] libtracefs: Do not allow tracefs_synth_set_instance() on created synth Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).