is_valid_value_type() looks up bpf_struct_ops_common_value in the
btf_vmlinux global, while every other lookup in it uses the btf it is
passed.  The id is a vmlinux id, and a module BTF resolves vmlinux ids
through its base BTF, so using the passed btf gives the same result.

Once the vmlinux BTF can be parsed on first use (later in this series),
struct_ops registrations made before that are applied by the parsing
task before it publishes the BTF, while btf_vmlinux is still NULL; the
registration then has to use the BTF it is given.

No functional change.

Signed-off-by: Jay Wang <[email protected]>
---
 kernel/bpf/bpf_struct_ops.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/bpf/bpf_struct_ops.c b/kernel/bpf/bpf_struct_ops.c
index 1178acd72296..a3d801a7e99f 100644
--- a/kernel/bpf/bpf_struct_ops.c
+++ b/kernel/bpf/bpf_struct_ops.c
@@ -103,8 +103,8 @@ static bool is_valid_value_type(struct btf *btf, s32 
value_id,
        }
        member = btf_type_member(vt);
        mt = btf_type_by_id(btf, member->type);
-       common_value_type = btf_type_by_id(btf_vmlinux,
-                                          
st_ops_ids[IDX_ST_OPS_COMMON_VALUE_ID]);
+       /* a vmlinux id: btf may be the vmlinux BTF being published, or a 
module's */
+       common_value_type = btf_type_by_id(btf, 
st_ops_ids[IDX_ST_OPS_COMMON_VALUE_ID]);
        if (mt != common_value_type) {
                pr_warn("The first member of %s should be 
bpf_struct_ops_common_value\n",
                        value_name);
-- 
2.47.3


Reply via email to