]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
bpf: Remove recursion call in btf_struct_access
authorJiri Olsa <jolsa@kernel.org>
Tue, 25 Aug 2020 19:21:16 +0000 (21:21 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 25 Aug 2020 22:37:41 +0000 (15:37 -0700)
Andrii suggested we can simply jump to again label
instead of making recursion call.

Suggested-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200825192124.710397-7-jolsa@kernel.org
kernel/bpf/btf.c

index ee0e2a5e6c8856d528ffbcad7b3b76d18476b7d9..4488c5b03941bcc401faba0037125a883edee389 100644 (file)
@@ -3931,14 +3931,13 @@ again:
                /* Only allow structure for now, can be relaxed for
                 * other types later.
                 */
-               elem_type = btf_type_skip_modifiers(btf_vmlinux,
-                                                   array_elem->type, NULL);
-               if (!btf_type_is_struct(elem_type))
+               t = btf_type_skip_modifiers(btf_vmlinux, array_elem->type,
+                                           NULL);
+               if (!btf_type_is_struct(t))
                        goto error;
 
-               off = (off - moff) % elem_type->size;
-               return btf_struct_access(log, elem_type, off, size, atype,
-                                        next_btf_id);
+               off = (off - moff) % t->size;
+               goto again;
 
 error:
                bpf_log(log, "access beyond struct %s at off %u size %u\n",