bpf: Fix bpf_dynptr_slice{_rdwr} to return NULL instead of 0
PATCH 1/1 bpf: Fix bpf_dynptr_slice{_rdwr} to return NULL instead of 0
Change bpf_dynptr_slice and bpf_dynptr_slice_rdwr to return NULL instead of 0, in accordance with the codebase guidelines.
Fixes 66e3a13e7c2c ("bpf: Add bpf_dynptr_slice and bpf_dynptr_slice_rdwr")
Reported-by kernel test robot <[email protected]>
Signed-off-by Joanne Koong <[email protected]>
--- kernel/bpf/helpers.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/bpf/helpers.c +4 -4
@@ -2227,11 +2227,11 @@ __bpf_kfunc void *bpf_dynptr_slice(const struct bpf_dynptr_kern *ptr, u32 offsetint err;if (!ptr->data) -return 0 ; +return NULL ; err =bpf_dynptr_check_off_len (ptr, offset, len);if (err) -return 0 ; +return NULL ; type =bpf_dynptr_get_type (ptr);
@@ -2252,7 +2252,7 @@ __bpf_kfunc void *bpf_dynptr_slice(const struct bpf_dynptr_kern *ptr, u32 offset }default :WARN_ONCE (true,"unknown dynptr type %d\n" , type); -return 0 ; +return NULL ; } }
@@ -2300,7 +2300,7 @@ __bpf_kfunc void *bpf_dynptr_slice_rdwr(const struct bpf_dynptr_kern *ptr, u32 o void *buffer, u32 buffer__szk) {if (!ptr->data ||bpf_dynptr_is_rdonly (ptr)) -return 0 ; +return NULL ;/* bpf_dynptr_slice_rdwr is the same logic as bpf_dynptr_slice. *
Signature · 1 line
2.34.1
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:
Quoted 8 lines · On Wed, 1 Mar 2023 21:30:14 -0800 you wrote:
Change
bpf_dynptr_sliceandbpf_dynptr_slice_rdwrto return NULL instead of 0, in accordance with the codebase guidelines.Fixes 66e3a13e7c2c ("bpf: Add bpf_dynptr_slice and bpf_dynptr_slice_rdwr")Reported-by kernel test robot <[email protected]>Signed-off-by Joanne Koong <[email protected]>[...]
Here is the summary with links:
- [v1,bpf-next] bpf: Fix bpf_dynptr_slice{_rdwr} to return NULL instead of 0
https://git.kernel.org/bpf/bpf-next/c/c45eac537bd8
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html