Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tracing: probes: Use __free() for trace_probe_log

Use __free() for trace_probe_log_clear() to cleanup error log interface.

Link: https://lore.kernel.org/all/175509538609.193596.16646724647358218778.stgit@devnote2/

Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

+9 -9
+2 -3
kernel/trace/trace_eprobe.c
··· 874 874 * Fetch args (no space): 875 875 * <name>=$<field>[:TYPE] 876 876 */ 877 + const char *trlog __free(trace_probe_log_clear) = NULL; 877 878 const char *event = NULL, *group = EPROBE_EVENT_SYSTEM; 878 879 const char *sys_event = NULL, *sys_name = NULL; 879 880 struct trace_event_call *event_call; ··· 888 887 if (argc < 2 || argv[0][0] != 'e') 889 888 return -ECANCELED; 890 889 891 - trace_probe_log_init("event_probe", argc, argv); 890 + trlog = trace_probe_log_init("event_probe", argc, argv); 892 891 893 892 event = strchr(&argv[0][1], ':'); 894 893 if (event) { ··· 988 987 goto error; 989 988 } 990 989 } 991 - trace_probe_log_clear(); 992 990 return ret; 993 991 994 992 mem_error: ··· 996 996 parse_error: 997 997 ret = -EINVAL; 998 998 error: 999 - trace_probe_log_clear(); 1000 999 trace_event_probe_cleanup(ep); 1001 1000 return ret; 1002 1001 }
+2 -1
kernel/trace/trace_probe.c
··· 156 156 static struct trace_probe_log trace_probe_log; 157 157 extern struct mutex dyn_event_ops_mutex; 158 158 159 - void trace_probe_log_init(const char *subsystem, int argc, const char **argv) 159 + const char *trace_probe_log_init(const char *subsystem, int argc, const char **argv) 160 160 { 161 161 lockdep_assert_held(&dyn_event_ops_mutex); 162 162 ··· 164 164 trace_probe_log.argc = argc; 165 165 trace_probe_log.argv = argv; 166 166 trace_probe_log.index = 0; 167 + return subsystem; 167 168 } 168 169 169 170 void trace_probe_log_clear(void)
+3 -1
kernel/trace/trace_probe.h
··· 578 578 int index; 579 579 }; 580 580 581 - void trace_probe_log_init(const char *subsystem, int argc, const char **argv); 581 + const char *trace_probe_log_init(const char *subsystem, int argc, const char **argv); 582 582 void trace_probe_log_set_index(int index); 583 583 void trace_probe_log_clear(void); 584 584 void __trace_probe_log_err(int offset, int err); 585 + 586 + DEFINE_FREE(trace_probe_log_clear, const char *, if (_T) trace_probe_log_clear()) 585 587 586 588 #define trace_probe_log_err(offs, err) \ 587 589 __trace_probe_log_err(offs, TP_ERR_##err)
+2 -4
kernel/trace/trace_uprobe.c
··· 539 539 */ 540 540 static int __trace_uprobe_create(int argc, const char **argv) 541 541 { 542 + const char *trlog __free(trace_probe_log_clear) = NULL; 542 543 const char *event = NULL, *group = UPROBE_EVENT_SYSTEM; 543 544 char *arg, *filename, *rctr, *rctr_end, *tmp; 544 545 unsigned long offset, ref_ctr_offset; ··· 566 565 if (argc < 2) 567 566 return -ECANCELED; 568 567 569 - trace_probe_log_init("trace_uprobe", argc, argv); 568 + trlog = trace_probe_log_init("trace_uprobe", argc, argv); 570 569 571 570 if (argc - 2 > MAX_TRACE_ARGS) { 572 571 trace_probe_log_set_index(2); ··· 598 597 if (ret) { 599 598 trace_probe_log_err(0, FILE_NOT_FOUND); 600 599 kfree(filename); 601 - trace_probe_log_clear(); 602 600 return ret; 603 601 } 604 602 if (!d_is_reg(path.dentry)) { ··· 728 728 error: 729 729 free_trace_uprobe(tu); 730 730 out: 731 - trace_probe_log_clear(); 732 731 return ret; 733 732 734 733 fail_mem: 735 734 ret = -ENOMEM; 736 735 737 736 fail_address_parse: 738 - trace_probe_log_clear(); 739 737 path_put(&path); 740 738 kfree(filename); 741 739