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
9191 for_each_member(i, type, member) {
9292 if (!member->name_off) {
9393 /* Anonymous union/struct: push it for later use */
94− type = btf_type_skip_modifiers(btf, member->type, &tid);
95− if (type && top < BTF_ANON_STACK_MAX) {
94+ if (btf_type_skip_modifiers(btf, member->type, &tid) &&
95+ top < BTF_ANON_STACK_MAX) {
9696 anon_stack[top].tid = tid;
9797 anon_stack[top++].offset =
9898 cur_offset + member->offset;