Skip to content

Commit d1624fd

Browse files
ytcoodeNobody
authored and
Nobody
committed
bpf: Simplify check in btf_parse_hdr()
Replace offsetof(hdr_len) + sizeof(hdr_len) with offsetofend(hdr_len) to simplify the check for correctness of btf_data_size in btf_parse_hdr() Signed-off-by: Yuntao Wang <[email protected]>
1 parent 0435357 commit d1624fd

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

kernel/bpf/btf.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4482,8 +4482,7 @@ static int btf_parse_hdr(struct btf_verifier_env *env)
44824482
btf = env->btf;
44834483
btf_data_size = btf->data_size;
44844484

4485-
if (btf_data_size <
4486-
offsetof(struct btf_header, hdr_len) + sizeof(hdr->hdr_len)) {
4485+
if (btf_data_size < offsetofend(struct btf_header, hdr_len)) {
44874486
btf_verifier_log(env, "hdr_len not found");
44884487
return -EINVAL;
44894488
}

0 commit comments

Comments
 (0)