qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2] virtio-net: fix the memory leak in rxfilter_


From: Andreas Färber
Subject: Re: [Qemu-devel] [PATCH v2] virtio-net: fix the memory leak in rxfilter_notify()
Date: Mon, 18 Nov 2013 16:59:23 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0

Am 18.11.2013 16:32, schrieb Amos Kong:
> object_get_canonical_path() returns a gchar*, it should be freeed by the
> caller.
> 

Cc: address@hidden

> Signed-off-by: Amos Kong <address@hidden>
> ---
> v2: put gchar *path inside rxfilter_notify_enabled block
> ---
>  hw/net/virtio-net.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index 613f144..b75c753 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -200,16 +200,16 @@ static void rxfilter_notify(NetClientState *nc)
>      VirtIONet *n = qemu_get_nic_opaque(nc);
>  
>      if (nc->rxfilter_notify_enabled) {
> +        gchar *path = object_get_canonical_path(OBJECT(n->qdev));
>          if (n->netclient_name) {
>              event_data = qobject_from_jsonf("{ 'name': %s, 'path': %s }",
> -                                    n->netclient_name,
> -                                    
> object_get_canonical_path(OBJECT(n->qdev)));
> +                                    n->netclient_name, path);

Now that the lengthy funtion call is gone, you could align the arguments
inside '(', but anyway:

Reviewed-by: Andreas Färber <address@hidden>

Thanks,
Andreas

>          } else {
> -            event_data = qobject_from_jsonf("{ 'path': %s }",
> -                                    
> object_get_canonical_path(OBJECT(n->qdev)));
> +            event_data = qobject_from_jsonf("{ 'path': %s }", path);
>          }
>          monitor_protocol_event(QEVENT_NIC_RX_FILTER_CHANGED, event_data);
>          qobject_decref(event_data);
> +        g_free(path);
>  
>          /* disable event notification to avoid events flooding */
>          nc->rxfilter_notify_enabled = 0;
> 


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



reply via email to

[Prev in Thread] Current Thread [Next in Thread]