Skip to content

Commit 948cc67

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 98ffb48 commit 948cc67

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)