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
Showing the changes to kernel (2 of 5 files). Show all
Unified · Split
| @@ -5217,6 +5217,7 @@ int unregister_ftrace_direct(unsigned long ip, unsigned long addr) · 5216 unmodified lines | ||
| 5217 | 5217 | { |
| 5218 | 5218 | struct ftrace_direct_func *direct; |
| 5219 | 5219 | struct ftrace_func_entry *entry; |
| 5220 | + struct ftrace_hash *hash; | |
| 5220 | 5221 | int ret = -ENODEV; |
| 5221 | 5222 | |
| 5222 | 5223 | mutex_lock(&direct_mutex); |
| @@ -5225,7 +5226,8 @@ int unregister_ftrace_direct(unsigned long ip, unsigned long addr) · 2 unmodified lines | ||
| 5225 | 5226 | if (!entry) |
| 5226 | 5227 | goto out_unlock; |
| 5227 | 5228 | |
| 5228 | − if (direct_functions->count == 1) | |
| 5229 | + hash = direct_ops.func_hash->filter_hash; | |
| 5230 | + if (hash->count == 1) | |
| 5229 | 5231 | unregister_ftrace_function(&direct_ops); |
| 5230 | 5232 | |
| 5231 | 5233 | 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 | ||
| 5540 | 5542 | err = unregister_ftrace_function(ops); |
| 5541 | 5543 | remove_direct_functions_hash(hash, addr); |
| 5542 | 5544 | mutex_unlock(&direct_mutex); |
| 5545 | + | |
| 5546 | + /* cleanup for possible another register call */ | |
| 5547 | + ops->func = NULL; | |
| 5548 | + ops->trampoline = 0; | |
| 5543 | 5549 | return err; |
| 5544 | 5550 | } |
| 5545 | 5551 | EXPORT_SYMBOL_GPL(unregister_ftrace_direct_multi); |
| @@ -1237,9 +1237,8 @@ static int __create_synth_event(const char *name, const char *raw_fields) · 1236 unmodified lines | ||
| 1237 | 1237 | argv + consumed, &consumed, |
| 1238 | 1238 | &field_version); |
| 1239 | 1239 | if (IS_ERR(field)) { |
| 1240 | − argv_free(argv); | |
| 1241 | 1240 | ret = PTR_ERR(field); |
| 1242 | − goto err; | |
| 1241 | + goto err_free_arg; | |
| 1243 | 1242 | } |
| 1244 | 1243 | |
| 1245 | 1244 | /* |
| @@ -1262,18 +1261,19 @@ static int __create_synth_event(const char *name, const char *raw_fields) · 16 unmodified lines | ||
| 1262 | 1261 | if (cmd_version > 1 && n_fields_this_loop >= 1) { |
| 1263 | 1262 | synth_err(SYNTH_ERR_INVALID_CMD, errpos(field_str)); |
| 1264 | 1263 | ret = -EINVAL; |
| 1265 | − goto err; | |
| 1264 | + goto err_free_arg; | |
| 1266 | 1265 | } |
| 1267 | 1266 | |
| 1268 | 1267 | fields[n_fields++] = field; |
| 1269 | 1268 | if (n_fields == SYNTH_FIELDS_MAX) { |
| 1270 | 1269 | synth_err(SYNTH_ERR_TOO_MANY_FIELDS, 0); |
| 1271 | 1270 | ret = -EINVAL; |
| 1272 | − goto err; | |
| 1271 | + goto err_free_arg; | |
| 1273 | 1272 | } |
| 1274 | 1273 | |
| 1275 | 1274 | n_fields_this_loop++; |
| 1276 | 1275 | } |
| 1276 | + argv_free(argv); | |
| 1277 | 1277 | |
| 1278 | 1278 | if (consumed < argc) { |
| 1279 | 1279 | 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 | ||
| 1281 | 1281 | goto err; |
| 1282 | 1282 | } |
| 1283 | 1283 | |
| 1284 | − argv_free(argv); | |
| 1285 | 1284 | } |
| 1286 | 1285 | |
| 1287 | 1286 | if (n_fields == 0) { |
| @@ -1307,6 +1306,8 @@ static int __create_synth_event(const char *name, const char *raw_fields) · 19 unmodified lines | ||
| 1307 | 1306 | kfree(saved_fields); |
| 1308 | 1307 | |
| 1309 | 1308 | return ret; |
| 1309 | + err_free_arg: | |
| 1310 | + argv_free(argv); | |
| 1310 | 1311 | err: |
| 1311 | 1312 | for (i = 0; i < n_fields; i++) |
| 1312 | 1313 | free_synth_field(fields[i]); |