Commit 16c5900b authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Andrii Nakryiko

bpf: Fix pointer cast warning

kp->addr is a pointer, so it cannot be cast directly to a 'u64'
when it gets interpreted as an integer value:

kernel/trace/bpf_trace.c: In function '____bpf_get_func_ip_kprobe':
kernel/trace/bpf_trace.c:968:21: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
  968 |         return kp ? (u64) kp->addr : 0;

Use the uintptr_t type instead.

Fixes: 9ffd9f3f ("bpf: Add bpf_get_func_ip helper for kprobe programs")
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210721212007.3876595-1-arnd@kernel.org
parent 807b8f0e
...@@ -965,7 +965,7 @@ BPF_CALL_1(bpf_get_func_ip_kprobe, struct pt_regs *, regs) ...@@ -965,7 +965,7 @@ BPF_CALL_1(bpf_get_func_ip_kprobe, struct pt_regs *, regs)
{ {
struct kprobe *kp = kprobe_running(); struct kprobe *kp = kprobe_running();
return kp ? (u64) kp->addr : 0; return kp ? (uintptr_t)kp->addr : 0;
} }
static const struct bpf_func_proto bpf_get_func_ip_proto_kprobe = { static const struct bpf_func_proto bpf_get_func_ip_proto_kprobe = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment