Function ksym_search() is used to parse address and return the symbol structure, when the address is out of range for kernel symbols it returns the symbol structure of kernel '_stext' entry; this introduces confusion and it misses the chance to intuitively tell the address is out of range.
This commit changes to use NULL pointer for failed to find symbol, user functions need to check the pointer is NULL and get to know the address has no corresponding kernel symbol for it. Signed-off-by: Leo Yan <leo....@linaro.org> --- samples/bpf/bpf_load.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/bpf/bpf_load.c b/samples/bpf/bpf_load.c index c2bf7ca..0c0584f 100644 --- a/samples/bpf/bpf_load.c +++ b/samples/bpf/bpf_load.c @@ -726,7 +726,7 @@ struct ksym *ksym_search(long key) /* valid ksym */ return &syms[start - 1]; - /* out of range. return _stext */ - return &syms[0]; + /* out of range. return NULL */ + return NULL; } -- 1.9.1