Skip to content

Commit 06e2ded

Browse files
x2018gregkh
authored andcommitted
tracing/uprobes: Check the return value of kstrdup() for tu->filename
[ Upstream commit 8c72242 ] 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/tencent_3C2E330722056D7891D2C83F29C802734B06@qq.com Acked-by: Masami Hiramatsu <mhiramat@kernel.org> Fixes: 33ea4b2 ("perf/core: Implement the 'perf_uprobe' PMU") Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent aadeb5d commit 06e2ded

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎kernel/trace/trace_uprobe.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,6 +1619,11 @@ create_local_trace_uprobe(char *name, unsigned long offs,
16191619
tu->path = path;
16201620
tu->ref_ctr_offset = ref_ctr_offset;
16211621
tu->filename = kstrdup(name, GFP_KERNEL);
1622+
if (!tu->filename) {
1623+
ret = -ENOMEM;
1624+
goto error;
1625+
}
1626+
16221627
init_trace_event_call(tu);
16231628

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

0 commit comments

Comments
 (0)