History

Merge tag 'trace-v5.16-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace

Pull tracing fixes from Steven Rostedt: "Tracing, ftrace and tracefs fixes: - Have tracefs honor the gid mount option - Have new files in tracefs inherit the parent ownership - Have direct_ops unregister when it has no more functions - Properly clean up the ops when unregistering multi direct ops - Add a sample module to test the multiple direct ops - Fix memory leak in error path of __create_synth_event()" * tag 'trace-v5.16-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: tracing: Fix possible memory leak in __create_synth_event() error path ftrace/samples: Add module to test multi direct modify interface ftrace: Add cleanup to unregister_ftrace_direct_multi ftrace: Use direct_ops hash in unregister_ftrace_direct tracefs: Set all files to the same group ownership as the mount option tracefs: Have new files inherit the ownership of their parent

Linus Torvalds committed 4 years ago

Commit 257dcf22 parents 0d21e66 c24be245 files · +242 −6Browse files

Showing the changes to kernel (2 of 5 files). Show all

Unified · Split

2 files
  1. kernel/trace/ftrace.c +7 −1
  2. kernel/trace/trace_events_synth.c +6 −5
kernel/trace/ftrace.c+7−1
@@ -5217,6 +5217,7 @@ int unregister_ftrace_direct(unsigned long ip, unsigned long addr) · 5216 unmodified lines
52175217 {
52185218 struct ftrace_direct_func *direct;
52195219 struct ftrace_func_entry *entry;
5220+ struct ftrace_hash *hash;
52205221 int ret = -ENODEV;
52215222
52225223 mutex_lock(&direct_mutex);
@@ -5225,7 +5226,8 @@ int unregister_ftrace_direct(unsigned long ip, unsigned long addr) · 2 unmodified lines
52255226 if (!entry)
52265227 goto out_unlock;
52275228
5228− if (direct_functions->count == 1)
5229+ hash = direct_ops.func_hash->filter_hash;
5230+ if (hash->count == 1)
52295231 unregister_ftrace_function(&direct_ops);
52305232
52315233 ret = ftrace_set_filter_ip(&direct_ops, ip, 1, 0);
@@ -5540,6 +5542,10 @@ int unregister_ftrace_direct_multi(struct ftrace_ops *ops, unsigned long addr) · 308 unmodified lines
55405542 err = unregister_ftrace_function(ops);
55415543 remove_direct_functions_hash(hash, addr);
55425544 mutex_unlock(&direct_mutex);
5545+
5546+ /* cleanup for possible another register call */
5547+ ops->func = NULL;
5548+ ops->trampoline = 0;
55435549 return err;
55445550 }
55455551 EXPORT_SYMBOL_GPL(unregister_ftrace_direct_multi);
kernel/trace/trace_events_synth.c+6−5
@@ -1237,9 +1237,8 @@ static int __create_synth_event(const char *name, const char *raw_fields) · 1236 unmodified lines
12371237 argv + consumed, &consumed,
12381238 &field_version);
12391239 if (IS_ERR(field)) {
1240− argv_free(argv);
12411240 ret = PTR_ERR(field);
1242− goto err;
1241+ goto err_free_arg;
12431242 }
12441243
12451244 /*
@@ -1262,18 +1261,19 @@ static int __create_synth_event(const char *name, const char *raw_fields) · 16 unmodified lines
12621261 if (cmd_version > 1 && n_fields_this_loop >= 1) {
12631262 synth_err(SYNTH_ERR_INVALID_CMD, errpos(field_str));
12641263 ret = -EINVAL;
1265− goto err;
1264+ goto err_free_arg;
12661265 }
12671266
12681267 fields[n_fields++] = field;
12691268 if (n_fields == SYNTH_FIELDS_MAX) {
12701269 synth_err(SYNTH_ERR_TOO_MANY_FIELDS, 0);
12711270 ret = -EINVAL;
1272− goto err;
1271+ goto err_free_arg;
12731272 }
12741273
12751274 n_fields_this_loop++;
12761275 }
1276+ argv_free(argv);
12771277
12781278 if (consumed < argc) {
12791279 synth_err(SYNTH_ERR_INVALID_CMD, 0);
@@ -1281,7 +1281,6 @@ static int __create_synth_event(const char *name, const char *raw_fields) · 1 unmodified line
12811281 goto err;
12821282 }
12831283
1284− argv_free(argv);
12851284 }
12861285
12871286 if (n_fields == 0) {
@@ -1307,6 +1306,8 @@ static int __create_synth_event(const char *name, const char *raw_fields) · 19 unmodified lines
13071306 kfree(saved_fields);
13081307
13091308 return ret;
1309+ err_free_arg:
1310+ argv_free(argv);
13101311 err:
13111312 for (i = 0; i < n_fields; i++)
13121313 free_synth_field(fields[i]);