Skip to content

Commit 9704669

Browse files
committed
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/ Fixes: 302db0f ("tracing/probes: Add a function to search a member of a struct/union") Cc: stable@vger.kernel.org Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
1 parent 841c351 commit 9704669

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/trace/trace_btf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ const struct btf_member *btf_find_struct_member(struct btf *btf,
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;

0 commit comments

Comments
 (0)