Skip to content

Commit 30c8fd3

Browse files
committed
tracing/kprobes: Fix to free objects when failed to copy a symbol
In __trace_kprobe_create(), if something fails it must goto error block to free objects. But when strdup() a symbol, it returns without that. Fix it to goto the error block to free objects correctly. Link: https://lore.kernel.org/all/173643297743.1514810.2408159540454241947.stgit@devnote2/ Fixes: 6212dd2 ("tracing/kprobes: Use dyn_event framework for kprobe events") Signed-off-by: Masami Hiramatsu (Google) <[email protected]> Reviewed-by: Steven Rostedt (Google) <[email protected]>
1 parent 9d89551 commit 30c8fd3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

kernel/trace/trace_kprobe.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -940,8 +940,10 @@ static int __trace_kprobe_create(int argc, const char *argv[])
940940
}
941941
/* a symbol specified */
942942
symbol = kstrdup(argv[1], GFP_KERNEL);
943-
if (!symbol)
944-
return -ENOMEM;
943+
if (!symbol) {
944+
ret = -ENOMEM;
945+
goto error;
946+
}
945947

946948
tmp = strchr(symbol, '%');
947949
if (tmp) {

0 commit comments

Comments
 (0)