[libvirt] [PATCH] util: do not leak handles in stop netlink event service

Wang King posted 1 patch 6 years, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20170513095915.18956-1-king.wang@huawei.com
src/util/virnetlink.c | 2 ++
1 file changed, 2 insertions(+)
[libvirt] [PATCH] util: do not leak handles in stop netlink event service
Posted by Wang King 6 years, 11 months ago
handles stored in virNetlinkEventSrvPrivatePtr should be freed when
stop netlink event service.
---
 src/util/virnetlink.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
index 92ecf77..b782cfa 100644
--- a/src/util/virnetlink.c
+++ b/src/util/virnetlink.c
@@ -758,6 +758,7 @@ virNetlinkEventServiceStop(unsigned int protocol)
     }
 
     server[protocol] = NULL;
+    VIR_FREE(srv->handles);
     virNetlinkEventServerUnlock(srv);
 
     virMutexDestroy(&srv->lock);
@@ -796,6 +797,7 @@ virNetlinkEventServiceStopAll(void)
         }
 
         server[i] = NULL;
+        VIR_FREE(srv->handles);
         virNetlinkEventServerUnlock(srv);
 
         virMutexDestroy(&srv->lock);
-- 
2.8.3


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] util: do not leak handles in stop netlink event service
Posted by John Ferlan 6 years, 11 months ago

On 05/13/2017 05:59 AM, Wang King wrote:
> handles stored in virNetlinkEventSrvPrivatePtr should be freed when
> stop netlink event service.
> ---
>  src/util/virnetlink.c | 2 ++
>  1 file changed, 2 insertions(+)
> 

This works and all, but do you you perhaps feel up to the challenge of
merging some code at all?

IOW: There's (almost) no reason why a "first" patch couldn't replace the
guts of the for loop in virNetlinkEventServiceStopAll (e.g. the "for (i
= 0; i < MAX_LINKS; i++)" with a call to virNetlinkEventServiceStop...

IOw:

   for (i = 0; i < MAX_LINKS; i++)
       virNetlinkEventServiceStop(i);

Where the VIR_FREE(srv->handles); is added to Stop in a second patch.

Tks -

John

> diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
> index 92ecf77..b782cfa 100644
> --- a/src/util/virnetlink.c
> +++ b/src/util/virnetlink.c
> @@ -758,6 +758,7 @@ virNetlinkEventServiceStop(unsigned int protocol)
>      }
>  
>      server[protocol] = NULL;
> +    VIR_FREE(srv->handles);
>      virNetlinkEventServerUnlock(srv);
>  
>      virMutexDestroy(&srv->lock);
> @@ -796,6 +797,7 @@ virNetlinkEventServiceStopAll(void)
>          }
>  
>          server[i] = NULL;
> +        VIR_FREE(srv->handles);
>          virNetlinkEventServerUnlock(srv);
>  
>          virMutexDestroy(&srv->lock);
> 

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