qemu-devel
[Top][All Lists]
Advanced

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

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


From: Michael S. Tsirkin
Subject: Re: [Qemu-devel] [PATCH] virtio-net: fix the memory leak in rxfilter_notify()
Date: Mon, 18 Nov 2013 15:55:08 +0200

On Mon, Nov 18, 2013 at 09:47:25PM +0800, Amos Kong wrote:
> object_get_canonical_path() returns a gchar*, it should be freeed by the
> caller.
> 
> Signed-off-by: Amos Kong <address@hidden>

Reviewed-by: Michael S. Tsirkin <address@hidden>

> ---
>  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..2b2fb57 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -198,15 +198,14 @@ static void rxfilter_notify(NetClientState *nc)
>  {
>      QObject *event_data;
>      VirtIONet *n = qemu_get_nic_opaque(nc);
> +    gchar *path = object_get_canonical_path(OBJECT(n->qdev));
>  
>      if (nc->rxfilter_notify_enabled) {

It would be a bit nicer to put gchar *path within this scope.

>          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);
>          } 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);
> @@ -214,6 +213,7 @@ static void rxfilter_notify(NetClientState *nc)
>          /* disable event notification to avoid events flooding */
>          nc->rxfilter_notify_enabled = 0;
>      }
> +    g_free(path);
>  }
>  
>  static char *mac_strdup_printf(const uint8_t *mac)
> -- 
> 1.8.3.1



reply via email to

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