Commit 87e9675
bpf: Call the missed btf_record_free() when map creation fails
When security_bpf_map_create() in map_create() fails, map_create() will
call btf_put() and ->map_free() callback to free the map. It doesn't
free the btf_record of map value, so add the missed btf_record_free()
when map creation fails.
However btf_record_free() needs to be called after ->map_free() just
like bpf_map_free_deferred() did, because ->map_free() may use the
btf_record to free the special fields in preallocated map value. So
factor out bpf_map_free() helper to free the map, btf_record, and btf
orderly and use the helper in both map_create() and
bpf_map_free_deferred().
Signed-off-by: Hou Tao <[email protected]>
Acked-by: Jiri Olsa <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>1 parent 211bf9c commit 87e9675
1 file changed
+12
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
735 | 735 | | |
736 | 736 | | |
737 | 737 | | |
738 | | - | |
739 | | - | |
| 738 | + | |
740 | 739 | | |
741 | | - | |
742 | 740 | | |
743 | 741 | | |
744 | 742 | | |
745 | | - | |
746 | | - | |
747 | 743 | | |
748 | 744 | | |
749 | 745 | | |
| |||
762 | 758 | | |
763 | 759 | | |
764 | 760 | | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
765 | 771 | | |
766 | 772 | | |
767 | 773 | | |
| |||
1413 | 1419 | | |
1414 | 1420 | | |
1415 | 1421 | | |
1416 | | - | |
1417 | | - | |
| 1422 | + | |
1418 | 1423 | | |
1419 | 1424 | | |
1420 | 1425 | | |
| |||
0 commit comments