[libvirt] [PATCH for 6.0.0] vircgroupv2devices: free BPF map when replacing with new one

Pavel Hrdina posted 1 patch 29 weeks ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/67522a0c8332af46ce3a4c118104d5dbad13fad6.1578921604.git.phrdina@redhat.com
src/util/vircgroupv2devices.c | 5 +++++
1 file changed, 5 insertions(+)

[libvirt] [PATCH for 6.0.0] vircgroupv2devices: free BPF map when replacing with new one

Posted by Pavel Hrdina 29 weeks ago
This leaks the FD of BPF map which means it will not be freed.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 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;
-- 
2.24.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH for 6.0.0] vircgroupv2devices: free BPF map when replacing with new one

Posted by Jiri Denemark 29 weeks ago
On Mon, Jan 13, 2020 at 14:20:26 +0100, Pavel Hrdina wrote:
> This leaks the FD of BPF map which means it will not be freed.
> 
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  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;

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list