Skip to content

Commit d0f0104

Browse files
Alexei Starovoitovborkmann
Alexei Starovoitov
authored andcommitted
bpf: Fix static checker warning
kernel/bpf/btf.c:4023 btf_distill_func_proto() error: potentially dereferencing uninitialized 't'. kernel/bpf/btf.c 4012 nargs = btf_type_vlen(func); 4013 if (nargs >= MAX_BPF_FUNC_ARGS) { 4014 bpf_log(log, 4015 "The function %s has %d arguments. Too many.\n", 4016 tname, nargs); 4017 return -EINVAL; 4018 } 4019 ret = __get_type_size(btf, func->type, &t); ^^ t isn't initialized for the first -EINVAL return This is unlikely path, since BTF should have been validated at this point. Fix it by returning 'void' BTF. Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent a95069e commit d0f0104

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

kernel/bpf/btf.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3976,8 +3976,10 @@ static int __get_type_size(struct btf *btf, u32 btf_id,
39763976
t = btf_type_by_id(btf, btf_id);
39773977
while (t && btf_type_is_modifier(t))
39783978
t = btf_type_by_id(btf, t->type);
3979-
if (!t)
3979+
if (!t) {
3980+
*bad_type = btf->types[0];
39803981
return -EINVAL;
3982+
}
39813983
if (btf_type_is_ptr(t))
39823984
/* kernel size of pointer. Not BPF's size of pointer*/
39833985
return sizeof(void *);

0 commit comments

Comments
 (0)