Commit e74881e
committed
src/config: free namespace table on success and failure
The per-thread namespace table (cg_namespace_table[]) is populated by
config_order_namespace_table() / config_validate_namespaces() under
cg_mount_table_lock and then consumed by cg_build_path_locked().
Before this patch we reset the array with a bespoke loop + memset at the
front of config_order_namespace_table(), but error paths relied on the
call chain eventually unwinding into cgroup_free_config() to release
any partially populated entries. That worked, yet it meant the table
could briefly hold dangling pointers after an error while the lock was
already dropped, one subtle slip or new return path would have left stale
namespaces visible to the rest of the library.
This change introduces a small helper,
cgroup_config_free_namespaces_table(), that walks the thread-local
array, frees each string, and nulls the slot. We invoke it in three
places:
- right at the start of config_order_namespace_table(), so every run
begins with a clean slate.
- from the error branches of both namespace helpers, guaranteeing that
even a mid-stream failure leaves the table empty before the lock is
released.
- and (unchanged) from cgroup_free_config(), so the happy path tears
everything down once the config work finishes.
The end result is both cleaner and safer: we delete the redundant
set-to-NULL/memset sequence and the namespace table is always in a known
state no matter how the parser exits.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>1 parent 58d73eb commit e74881e
1 file changed
+18
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
963 | 963 | | |
964 | 964 | | |
965 | 965 | | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
966 | 979 | | |
967 | 980 | | |
968 | 981 | | |
| |||
1050 | 1063 | | |
1051 | 1064 | | |
1052 | 1065 | | |
| 1066 | + | |
| 1067 | + | |
1053 | 1068 | | |
1054 | 1069 | | |
1055 | 1070 | | |
| |||
1073 | 1088 | | |
1074 | 1089 | | |
1075 | 1090 | | |
1076 | | - | |
1077 | | - | |
1078 | | - | |
1079 | | - | |
1080 | | - | |
| 1091 | + | |
1081 | 1092 | | |
1082 | 1093 | | |
1083 | 1094 | | |
| |||
1110 | 1121 | | |
1111 | 1122 | | |
1112 | 1123 | | |
| 1124 | + | |
| 1125 | + | |
1113 | 1126 | | |
1114 | 1127 | | |
1115 | 1128 | | |
| |||
0 commit comments