Skip to content

Commit 035ba76

Browse files
committed
tracing/probes: cleanup: Set trace_probe::nr_args at trace_probe_init
Instead of incrementing the trace_probe::nr_args, init it at trace_probe_init(). Without this change, there is no way to get the number of trace_probe arguments while parsing it. This is a cleanup, so the behavior is not changed. Link: https://lore.kernel.org/all/170952363585.229804.13060759900346411951.stgit@devnote2/ Signed-off-by: Masami Hiramatsu (Google) <[email protected]>
1 parent 032330a commit 035ba76

File tree

6 files changed

+11
-9
lines changed

6 files changed

+11
-9
lines changed

kernel/trace/trace_eprobe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ static struct trace_eprobe *alloc_event_probe(const char *group,
220220
if (!ep->event_system)
221221
goto error;
222222

223-
ret = trace_probe_init(&ep->tp, this_event, group, false);
223+
ret = trace_probe_init(&ep->tp, this_event, group, false, nargs);
224224
if (ret < 0)
225225
goto error;
226226

kernel/trace/trace_fprobe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ static struct trace_fprobe *alloc_trace_fprobe(const char *group,
389389
tf->tpoint = tpoint;
390390
tf->fp.nr_maxactive = maxactive;
391391

392-
ret = trace_probe_init(&tf->tp, event, group, false);
392+
ret = trace_probe_init(&tf->tp, event, group, false, nargs);
393393
if (ret < 0)
394394
goto error;
395395

kernel/trace/trace_kprobe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ static struct trace_kprobe *alloc_trace_kprobe(const char *group,
290290
INIT_HLIST_NODE(&tk->rp.kp.hlist);
291291
INIT_LIST_HEAD(&tk->rp.kp.list);
292292

293-
ret = trace_probe_init(&tk->tp, event, group, false);
293+
ret = trace_probe_init(&tk->tp, event, group, false, nargs);
294294
if (ret < 0)
295295
goto error;
296296

kernel/trace/trace_probe.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,9 +1423,6 @@ int traceprobe_parse_probe_arg(struct trace_probe *tp, int i, const char *arg,
14231423
struct probe_arg *parg = &tp->args[i];
14241424
const char *body;
14251425

1426-
/* Increment count for freeing args in error case */
1427-
tp->nr_args++;
1428-
14291426
body = strchr(arg, '=');
14301427
if (body) {
14311428
if (body - arg > MAX_ARG_NAME_LEN) {
@@ -1810,7 +1807,7 @@ void trace_probe_cleanup(struct trace_probe *tp)
18101807
}
18111808

18121809
int trace_probe_init(struct trace_probe *tp, const char *event,
1813-
const char *group, bool alloc_filter)
1810+
const char *group, bool alloc_filter, int nargs)
18141811
{
18151812
struct trace_event_call *call;
18161813
size_t size = sizeof(struct trace_probe_event);
@@ -1846,6 +1843,11 @@ int trace_probe_init(struct trace_probe *tp, const char *event,
18461843
goto error;
18471844
}
18481845

1846+
tp->nr_args = nargs;
1847+
/* Make sure pointers in args[] are NULL */
1848+
if (nargs)
1849+
memset(tp->args, 0, sizeof(tp->args[0]) * nargs);
1850+
18491851
return 0;
18501852

18511853
error:

kernel/trace/trace_probe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ static inline bool trace_probe_has_single_file(struct trace_probe *tp)
338338
}
339339

340340
int trace_probe_init(struct trace_probe *tp, const char *event,
341-
const char *group, bool alloc_filter);
341+
const char *group, bool alloc_filter, int nargs);
342342
void trace_probe_cleanup(struct trace_probe *tp);
343343
int trace_probe_append(struct trace_probe *tp, struct trace_probe *to);
344344
void trace_probe_unlink(struct trace_probe *tp);

kernel/trace/trace_uprobe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ alloc_trace_uprobe(const char *group, const char *event, int nargs, bool is_ret)
337337
if (!tu)
338338
return ERR_PTR(-ENOMEM);
339339

340-
ret = trace_probe_init(&tu->tp, event, group, true);
340+
ret = trace_probe_init(&tu->tp, event, group, true, nargs);
341341
if (ret < 0)
342342
goto error;
343343

0 commit comments

Comments
 (0)