Commit 5bad3587 authored by Stanislav Fomichev's avatar Stanislav Fomichev Committed by Daniel Borkmann

bpf: Unify and simplify btf_func_proto_check error handling

Replace 'err = x; break;' with 'return x;'.
Suggested-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Signed-off-by: default avatarStanislav Fomichev <sdf@google.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20221124002838.2700179-1-sdf@google.com
parent 72b43bde
...@@ -4779,7 +4779,6 @@ static int btf_func_proto_check(struct btf_verifier_env *env, ...@@ -4779,7 +4779,6 @@ static int btf_func_proto_check(struct btf_verifier_env *env,
nr_args--; nr_args--;
} }
err = 0;
for (i = 0; i < nr_args; i++) { for (i = 0; i < nr_args; i++) {
const struct btf_type *arg_type; const struct btf_type *arg_type;
u32 arg_type_id; u32 arg_type_id;
...@@ -4788,8 +4787,7 @@ static int btf_func_proto_check(struct btf_verifier_env *env, ...@@ -4788,8 +4787,7 @@ static int btf_func_proto_check(struct btf_verifier_env *env,
arg_type = btf_type_by_id(btf, arg_type_id); arg_type = btf_type_by_id(btf, arg_type_id);
if (!arg_type) { if (!arg_type) {
btf_verifier_log_type(env, t, "Invalid arg#%u", i + 1); btf_verifier_log_type(env, t, "Invalid arg#%u", i + 1);
err = -EINVAL; return -EINVAL;
break;
} }
if (btf_type_is_resolve_source_only(arg_type)) { if (btf_type_is_resolve_source_only(arg_type)) {
...@@ -4802,25 +4800,23 @@ static int btf_func_proto_check(struct btf_verifier_env *env, ...@@ -4802,25 +4800,23 @@ static int btf_func_proto_check(struct btf_verifier_env *env,
!btf_name_valid_identifier(btf, args[i].name_off))) { !btf_name_valid_identifier(btf, args[i].name_off))) {
btf_verifier_log_type(env, t, btf_verifier_log_type(env, t,
"Invalid arg#%u", i + 1); "Invalid arg#%u", i + 1);
err = -EINVAL; return -EINVAL;
break;
} }
if (btf_type_needs_resolve(arg_type) && if (btf_type_needs_resolve(arg_type) &&
!env_type_is_resolved(env, arg_type_id)) { !env_type_is_resolved(env, arg_type_id)) {
err = btf_resolve(env, arg_type, arg_type_id); err = btf_resolve(env, arg_type, arg_type_id);
if (err) if (err)
break; return err;
} }
if (!btf_type_id_size(btf, &arg_type_id, NULL)) { if (!btf_type_id_size(btf, &arg_type_id, NULL)) {
btf_verifier_log_type(env, t, "Invalid arg#%u", i + 1); btf_verifier_log_type(env, t, "Invalid arg#%u", i + 1);
err = -EINVAL; return -EINVAL;
break;
} }
} }
return err; return 0;
} }
static int btf_func_check(struct btf_verifier_env *env, static int btf_func_check(struct btf_verifier_env *env,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment