Skip to content

Commit 8a89668

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 9378a87 commit 8a89668

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
@@ -4480,8 +4480,7 @@ static int btf_parse_hdr(struct btf_verifier_env *env)
44804480
btf = env->btf;
44814481
btf_data_size = btf->data_size;
44824482

4483-
if (btf_data_size <
4484-
offsetof(struct btf_header, hdr_len) + sizeof(hdr->hdr_len)) {
4483+
if (btf_data_size < offsetofend(struct btf_header, hdr_len)) {
44854484
btf_verifier_log(env, "hdr_len not found");
44864485
return -EINVAL;
44874486
}

0 commit comments

Comments
 (0)