Blob Blame History Raw
From: Song Liu <songliubraving@fb.com>
Date: Thu, 2 Jul 2020 19:45:37 -0700
Subject: bpf: Fix build without CONFIG_STACKTRACE
Patch-mainline: v5.9-rc1
Git-commit: 046cc3dd9a2507b8e111714807ab8bf15ea5bb70
References: bsc#1177028

Without CONFIG_STACKTRACE stack_trace_save_tsk() is not defined. Let
get_callchain_entry_for_task() to always return NULL in such cases.

Fixes: fa28dcb82a38 ("bpf: Introduce helper bpf_get_task_stack()")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200703024537.79971-1-songliubraving@fb.com
Acked-by: Gary Lin <glin@suse.com>
---
 kernel/bpf/stackmap.c |    4 ++++
 1 file changed, 4 insertions(+)

--- a/kernel/bpf/stackmap.c
+++ b/kernel/bpf/stackmap.c
@@ -358,6 +358,7 @@ static void stack_map_get_build_id_offse
 static struct perf_callchain_entry *
 get_callchain_entry_for_task(struct task_struct *task, u32 init_nr)
 {
+#ifdef CONFIG_STACKTRACE
 	struct perf_callchain_entry *entry;
 	int rctx;
 
@@ -387,6 +388,9 @@ get_callchain_entry_for_task(struct task
 	put_callchain_entry(rctx);
 
 	return entry;
+#else /* CONFIG_STACKTRACE */
+	return NULL;
+#endif
 }
 
 BPF_CALL_3(bpf_get_stackid, struct pt_regs *, regs, struct bpf_map *, map,