]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
tracing/uprobes: Check the return value of kstrdup() for tu->filename
authorXiaoke Wang <xkernel.wang@foxmail.com>
Tue, 14 Dec 2021 01:28:02 +0000 (09:28 +0800)
committerPaolo Pisati <paolo.pisati@canonical.com>
Wed, 9 Mar 2022 14:17:48 +0000 (15:17 +0100)
BugLink: https://bugs.launchpad.net/bugs/1964361
[ Upstream commit 8c7224245557707c613f130431cafbaaa4889615 ]

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: 33ea4b24277b ("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>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
kernel/trace/trace_uprobe.c

index f5f0039d31e5aa9edda0344dd271e90f1d2f4c15..78ec1c16ccf4b7a64b05536c6ecd64c594c810c1 100644 (file)
@@ -1619,6 +1619,11 @@ create_local_trace_uprobe(char *name, unsigned long offs,
        tu->path = path;
        tu->ref_ctr_offset = ref_ctr_offset;
        tu->filename = kstrdup(name, GFP_KERNEL);
+       if (!tu->filename) {
+               ret = -ENOMEM;
+               goto error;
+       }
+
        init_trace_event_call(tu);
 
        ptype = is_ret_probe(tu) ? PROBE_PRINT_RETURN : PROBE_PRINT_NORMAL;