File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -694,11 +694,16 @@ static void bpf_map_free_deferred(struct work_struct *work)
694694{
695695 struct bpf_map * map = container_of (work , struct bpf_map , work );
696696 struct btf_record * rec = map -> record ;
697+ struct btf * btf = map -> btf ;
697698
698699 security_bpf_map_free (map );
699700 bpf_map_release_memcg (map );
700701 /* implementation dependent freeing */
701702 map -> ops -> map_free (map );
703+ /* Delay freeing of btf for maps, as map_free callback may need
704+ * struct_meta info which will be freed with btf_put().
705+ */
706+ btf_put (btf );
702707 /* Delay freeing of btf_record for maps, as map_free
703708 * callback usually needs access to them. It is better to do it here
704709 * than require each callback to do the free itself manually.
@@ -727,7 +732,6 @@ void bpf_map_put(struct bpf_map *map)
727732 if (atomic64_dec_and_test (& map -> refcnt )) {
728733 /* bpf_map_free_id() must be called first */
729734 bpf_map_free_id (map );
730- btf_put (map -> btf );
731735 INIT_WORK (& map -> work , bpf_map_free_deferred );
732736 /* Avoid spawning kworkers, since they all might contend
733737 * for the same mutex like slab_mutex.
You can’t perform that action at this time.
0 commit comments