From 7d608469621a3fda72dff2a89308e68cc9fb4c9a Mon Sep 17 00:00:00 2001 From: Pavel Hrdina Date: Mon, 13 Jan 2020 12:50:41 +0100 Subject: [PATCH] vircgroupv2devices: free BPF map when replacing with new one This leaks the FD of BPF map which means it will not be freed. Signed-off-by: Pavel Hrdina Reviewed-by: Jiri Denemark --- src/util/vircgroupv2devices.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/util/vircgroupv2devices.c b/src/util/vircgroupv2devices.c index 402ce3f86f..445f9c53fc 100644 --- a/src/util/vircgroupv2devices.c +++ b/src/util/vircgroupv2devices.c @@ -311,6 +311,11 @@ virCgroupV2DevicesAttachProg(virCgroupPtr group, VIR_FORCE_CLOSE(group->unified.devices.progfd); } + if (group->unified.devices.mapfd > 0) { + VIR_DEBUG("Closing existing map that was replaced by new one."); + VIR_FORCE_CLOSE(group->unified.devices.mapfd); + } + group->unified.devices.progfd = progfd; group->unified.devices.mapfd = mapfd; group->unified.devices.max = max; -- GitLab