Skip to content

Commit 8c72242

Browse files
x2018rostedt
authored andcommitted
tracing/uprobes: Check the return value of kstrdup() for tu->filename
kstrdup() returns NULL when some internal memory errors happen, it is better to check the return value of it so to catch the memory error in time. Link: https://lkml.kernel.org/r/[email protected] Acked-by: Masami Hiramatsu <[email protected]> Fixes: 33ea4b2 ("perf/core: Implement the 'perf_uprobe' PMU") Signed-off-by: Xiaoke Wang <[email protected]> Signed-off-by: Steven Rostedt <[email protected]>
1 parent 289e7b0 commit 8c72242

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

kernel/trace/trace_uprobe.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,6 +1609,11 @@ create_local_trace_uprobe(char *name, unsigned long offs,
16091609
tu->path = path;
16101610
tu->ref_ctr_offset = ref_ctr_offset;
16111611
tu->filename = kstrdup(name, GFP_KERNEL);
1612+
if (!tu->filename) {
1613+
ret = -ENOMEM;
1614+
goto error;
1615+
}
1616+
16121617
init_trace_event_call(tu);
16131618

16141619
ptype = is_ret_probe(tu) ? PROBE_PRINT_RETURN : PROBE_PRINT_NORMAL;

0 commit comments

Comments
 (0)