History

tracing/probes: Fix to search structure fields correctly

Fix to search a field from the structure which has anonymous union correctly. Since the reference `type` pointer was updated in the loop, the search loop suddenly aborted where it hits an anonymous union. Thus it can not find the field after the anonymous union. This avoids updating the cursor `type` pointer in the loop. Link: https://lore.kernel.org/all/170791694361.389532.10047514554799419688.stgit@devnote2/

Masami Hiramatsu (Google) committed 2 years ago

Commit 97046691 parent 841c3511 file · +2 −2Browse files

Unified · Split

kernel/trace/trace_btf.c+2−2
@@ -91,8 +91,8 @@ retry: · 90 unmodified lines
91 for_each_member(i, type, member) {91 for_each_member(i, type, member) {
92 if (!member->name_off) {92 if (!member->name_off) {
93 /* Anonymous union/struct: push it for later use */93 /* Anonymous union/struct: push it for later use */
94 type = btf_type_skip_modifiers(btf, member->type, &tid);94 if (btf_type_skip_modifiers(btf, member->type, &tid) &&
95 if (type && top < BTF_ANON_STACK_MAX) {95 top < BTF_ANON_STACK_MAX) {
96 anon_stack[top].tid = tid;96 anon_stack[top].tid = tid;
97 anon_stack[top++].offset =97 anon_stack[top++].offset =
98 cur_offset + member->offset;98 cur_offset + member->offset;