qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] virtio-net: fix the memory leak in rxfilter_notify()
@ 2013-11-18 15:32 Amos Kong
  2013-11-18 15:44 ` Michael S. Tsirkin
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Amos Kong @ 2013-11-18 15:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: vyasevic, stefanha, mst

object_get_canonical_path() returns a gchar*, it should be freeed by the
caller.

Signed-off-by: Amos Kong <akong@redhat.com>
---
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);
         } 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;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v2] virtio-net: fix the memory leak in rxfilter_notify()
  2013-11-18 15:32 [Qemu-devel] [PATCH v2] virtio-net: fix the memory leak in rxfilter_notify() Amos Kong
@ 2013-11-18 15:44 ` Michael S. Tsirkin
  2013-11-18 15:51 ` Vlad Yasevich
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2013-11-18 15:44 UTC (permalink / raw)
  To: Amos Kong; +Cc: vyasevic, qemu-devel, stefanha

On Mon, Nov 18, 2013 at 11:32:17PM +0800, Amos Kong wrote:
> object_get_canonical_path() returns a gchar*, it should be freeed by the
> caller.
> 
> Signed-off-by: Amos Kong <akong@redhat.com>

Reviewed-by: Michael S. Tsirkin <mst@redhat.com>

> ---
> 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);
>          } 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;
> -- 
> 1.8.3.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v2] virtio-net: fix the memory leak in rxfilter_notify()
  2013-11-18 15:32 [Qemu-devel] [PATCH v2] virtio-net: fix the memory leak in rxfilter_notify() Amos Kong
  2013-11-18 15:44 ` Michael S. Tsirkin
@ 2013-11-18 15:51 ` Vlad Yasevich
  2013-11-18 15:59 ` Andreas Färber
  2013-11-19  8:46 ` Stefan Hajnoczi
  3 siblings, 0 replies; 5+ messages in thread
From: Vlad Yasevich @ 2013-11-18 15:51 UTC (permalink / raw)
  To: Amos Kong, qemu-devel; +Cc: stefanha, mst

On 11/18/2013 10:32 AM, Amos Kong wrote:
> object_get_canonical_path() returns a gchar*, it should be freeed by the
> caller.
> 
> Signed-off-by: Amos Kong <akong@redhat.com>

Reviewed-by: Vlad Yasevich <vyasevic@redhat.com>

-vlad

> ---
> 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);
>          } 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;
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v2] virtio-net: fix the memory leak in rxfilter_notify()
  2013-11-18 15:32 [Qemu-devel] [PATCH v2] virtio-net: fix the memory leak in rxfilter_notify() Amos Kong
  2013-11-18 15:44 ` Michael S. Tsirkin
  2013-11-18 15:51 ` Vlad Yasevich
@ 2013-11-18 15:59 ` Andreas Färber
  2013-11-19  8:46 ` Stefan Hajnoczi
  3 siblings, 0 replies; 5+ messages in thread
From: Andreas Färber @ 2013-11-18 15:59 UTC (permalink / raw)
  To: Amos Kong, qemu-devel; +Cc: vyasevic, qemu-stable, stefanha, mst

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

Cc: qemu-stable@nongnu.org

> Signed-off-by: Amos Kong <akong@redhat.com>
> ---
> 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 <afaerber@suse.de>

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v2] virtio-net: fix the memory leak in rxfilter_notify()
  2013-11-18 15:32 [Qemu-devel] [PATCH v2] virtio-net: fix the memory leak in rxfilter_notify() Amos Kong
                   ` (2 preceding siblings ...)
  2013-11-18 15:59 ` Andreas Färber
@ 2013-11-19  8:46 ` Stefan Hajnoczi
  3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2013-11-19  8:46 UTC (permalink / raw)
  To: Amos Kong; +Cc: vyasevic, qemu-devel, mst

On Mon, Nov 18, 2013 at 11:32:17PM +0800, Amos Kong wrote:
> object_get_canonical_path() returns a gchar*, it should be freeed by the
> caller.
> 
> Signed-off-by: Amos Kong <akong@redhat.com>
> ---
> v2: put gchar *path inside rxfilter_notify_enabled block
> ---
>  hw/net/virtio-net.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

Thanks, applied to my net tree:
https://github.com/stefanha/qemu/commits/net

Stefan

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-11-19  8:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-18 15:32 [Qemu-devel] [PATCH v2] virtio-net: fix the memory leak in rxfilter_notify() Amos Kong
2013-11-18 15:44 ` Michael S. Tsirkin
2013-11-18 15:51 ` Vlad Yasevich
2013-11-18 15:59 ` Andreas Färber
2013-11-19  8:46 ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).