Skip to content

Commit 7af227f

Browse files
kaixuxiakxkernel-patches-bot
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. Fixes coccicheck warning: ./kernel/bpf/verifier.c:9616:5-15: WARNING: Unsigned expression compared with zero: datasec_id > 0 Reported-by: Tosk Robot <tencent_os_robot@tencent.com> Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
1 parent 9da615a commit 7af227f

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,7 +9572,8 @@ 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;
9575+
s32 datasec_id;
9576+
u32 type, id = insn->imm;
95769577
const struct btf_var_secinfo *vsi;
95779578
const struct btf_type *datasec;
95789579
const struct btf_type *t;

0 commit comments

Comments
 (0)