Skip to contentSkip to conversation

bpf: Remove unnecessary err < 0 check in bpf_struct_ops_map_update_elem

PATCH Applied Martin KaFai Lau 3 participants 3 messages Mar 15, 2024 – Mar 18, 2024 BPF

lore
Share & tools
lore

Martin KaFai Lau

author reviewer
#0 lore raw

PATCH 1/1 bpf: Remove unnecessary err < 0 check in bpf_struct_ops_map_update_elem

From: Martin KaFai Lau <[email protected]>

There is a "if (err)" check earlier, so the "if (err < 0)" check that this patch removing is unnecessary. It was my overlook when making adjustments to the bpf_struct_ops_prepare_trampoline() such that the caller does not have to worry about the new page when the function returns error.

Cc Kui-Feng Lee <[email protected]>
Fixes 187e2af05abe ("bpf: struct_ops supports more than one page for trampolines.")
---
 kernel/bpf/bpf_struct_ops.c | 2 --
 1 file changed, 2 deletions(-)
kernel/bpf/bpf_struct_ops.c +0 -2
index 43356faaa057..3fcd35314ce5 100644
@@ -728,8 +728,6 @@ static long bpf_struct_ops_map_update_elem(struct bpf_map *map, void *key,
 			cur_image = image;
 			trampoline_start = 0;
 		}
-		if (err < 0)
-			goto reset_unlock;
 
 		*(void **)(kdata + moff) = image + trampoline_start + cfi_get_offset();
 
Signature · 1 line
2.43.0
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Martin KaFai Lau

From: Martin KaFai Lau <[email protected]>

There is a "if (err)" check earlier, so the "if (err < 0)" check that this patch removing is unnecessary. It was my overlook when making adjustments to the bpf_struct_ops_prepare_trampoline() such that the caller does not have to worry about the new page when the function returns error.

Cc Kui-Feng Lee <[email protected]>
Fixes 187e2af05abe ("bpf: struct_ops supports more than one page for trampolines.")
#2 lore raw
In reply to Martin KaFai Lau
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 9 lines · On Fri, 15 Mar 2024 12:21:12 -0700 you wrote:

From: Martin KaFai Lau <[email protected]>

There is a "if (err)" check earlier, so the "if (err < 0)" check that this patch removing is unnecessary. It was my overlook when making adjustments to the bpf_struct_ops_prepare_trampoline() such that the caller does not have to worry about the new page when the function returns error.

[...]

Here is the summary with links:
- [bpf-next] bpf: Remove unnecessary err < 0 check in bpf_struct_ops_map_update_elem

    https://git.kernel.org/bpf/bpf-next/c/7f3edd0c72c3

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html