Commit f87d39d
libbpf: close map fd if init map slots failed
Previously we forgot to close the map fd if bpf_map_update_elem()
failed during map slot init, which will leak map fd.
Let's move map slot initialization to new function init_map_slots() to
simplify the code. And close the map fd if init slot failed.
Reported-by: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Acked-by: Andrii Nakryiko <andrii@kernel.org>1 parent 07d2e5a commit f87d39d
1 file changed
+34
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4203 | 4203 | | |
4204 | 4204 | | |
4205 | 4205 | | |
| 4206 | + | |
| 4207 | + | |
| 4208 | + | |
| 4209 | + | |
| 4210 | + | |
| 4211 | + | |
| 4212 | + | |
| 4213 | + | |
| 4214 | + | |
| 4215 | + | |
| 4216 | + | |
| 4217 | + | |
| 4218 | + | |
| 4219 | + | |
| 4220 | + | |
| 4221 | + | |
| 4222 | + | |
| 4223 | + | |
| 4224 | + | |
| 4225 | + | |
| 4226 | + | |
| 4227 | + | |
| 4228 | + | |
| 4229 | + | |
| 4230 | + | |
| 4231 | + | |
| 4232 | + | |
| 4233 | + | |
| 4234 | + | |
| 4235 | + | |
4206 | 4236 | | |
4207 | 4237 | | |
4208 | 4238 | | |
| |||
4245 | 4275 | | |
4246 | 4276 | | |
4247 | 4277 | | |
4248 | | - | |
4249 | | - | |
4250 | | - | |
4251 | | - | |
4252 | | - | |
4253 | | - | |
4254 | | - | |
4255 | | - | |
4256 | | - | |
4257 | | - | |
4258 | | - | |
4259 | | - | |
4260 | | - | |
4261 | | - | |
4262 | | - | |
4263 | | - | |
4264 | | - | |
4265 | | - | |
4266 | | - | |
| 4278 | + | |
| 4279 | + | |
| 4280 | + | |
| 4281 | + | |
4267 | 4282 | | |
4268 | | - | |
4269 | | - | |
4270 | 4283 | | |
4271 | 4284 | | |
4272 | 4285 | | |
| |||
0 commit comments