Skip to content

Commit f16e631

Browse files
kaixuxiakxborkmann
authored andcommitted
bpf: Fix unsigned 'datasec_id' compared with zero in check_pseudo_btf_id
The unsigned variable datasec_id is assigned a return value from the call to check_pseudo_btf_id(), which may return negative error code. This fixes the following coccicheck warning: ./kernel/bpf/verifier.c:9616:5-15: WARNING: Unsigned expression compared with zero: datasec_id > 0 Fixes: eaa6bcb ("bpf: Introduce bpf_per_cpu_ptr()") Reported-by: Tosk Robot <[email protected]> Signed-off-by: Kaixu Xia <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Acked-by: John Fastabend <[email protected]> Cc: Hao Luo <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent abbaa43 commit f16e631

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

kernel/bpf/verifier.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9572,12 +9572,13 @@ static int check_pseudo_btf_id(struct bpf_verifier_env *env,
95729572
struct bpf_insn *insn,
95739573
struct bpf_insn_aux_data *aux)
95749574
{
9575-
u32 datasec_id, type, id = insn->imm;
95769575
const struct btf_var_secinfo *vsi;
95779576
const struct btf_type *datasec;
95789577
const struct btf_type *t;
95799578
const char *sym_name;
95809579
bool percpu = false;
9580+
u32 type, id = insn->imm;
9581+
s32 datasec_id;
95819582
u64 addr;
95829583
int i;
95839584

0 commit comments

Comments
 (0)