qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] migration: tls: fix memory leak in migration_tls_get_creds
@ 2020-07-22  3:32 Zhenyu Ye
  2020-07-22  9:15 ` Daniel P. Berrangé
  2020-08-27 17:36 ` Dr. David Alan Gilbert
  0 siblings, 2 replies; 3+ messages in thread
From: Zhenyu Ye @ 2020-07-22  3:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: berrange, quintela, yezhenyu2, dgilbert, xiexiangyou, zhengchuan

Currently migration_tls_get_creds() adds the reference of creds
but there was no place to unref it.  So the OBJECT(creds) will
never be freed and result in memory leak.

The leak stack:
Direct leak of 104 byte(s) in 1 object(s) allocated from:
    #0 0xffffa88bd20b in __interceptor_malloc (/usr/lib64/libasan.so.4+0xd320b)
    #1 0xffffa7f0cb1b in g_malloc (/usr/lib64/libglib-2.0.so.0+0x58b1b)
    #2 0x14b58cb in object_new_with_type qom/object.c:634
    #3 0x14b597b in object_new qom/object.c:645
    #4 0x14c0e4f in user_creatable_add_type qom/object_interfaces.c:59
    #5 0x141c78b in qmp_object_add qom/qom-qmp-cmds.c:312
    #6 0x140e513 in qmp_marshal_object_add qapi/qapi-commands-qom.c:279
    #7 0x176ba97 in do_qmp_dispatch qapi/qmp-dispatch.c:165
    #8 0x176bee7 in qmp_dispatch qapi/qmp-dispatch.c:208
    #9 0x136e337 in monitor_qmp_dispatch monitor/qmp.c:150
    #10 0x136eae3 in monitor_qmp_bh_dispatcher monitor/qmp.c:239
    #11 0x1852e93 in aio_bh_call util/async.c:89
    #12 0x18531b7 in aio_bh_poll util/async.c:117
    #13 0x18616bf in aio_dispatch util/aio-posix.c:459
    #14 0x1853f37 in aio_ctx_dispatch util/async.c:268
    #15 0xffffa7f06a7b in g_main_context_dispatch (/usr/lib64/libglib-2.0.so.0+0x52a7b)

Since we're fine to use the borrowed reference when using the creds,
so just remove the object_ref() in migration_tls_get_creds().

Signed-off-by: Zhenyu Ye <yezhenyu2@huawei.com>
---
 migration/tls.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/migration/tls.c b/migration/tls.c
index 5171afc6c4..7a02ec8656 100644
--- a/migration/tls.c
+++ b/migration/tls.c
@@ -58,7 +58,6 @@ migration_tls_get_creds(MigrationState *s,
         return NULL;
     }
 
-    object_ref(OBJECT(ret));
     return ret;
 }
 
-- 
2.19.1




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

* Re: [PATCH v1] migration: tls: fix memory leak in migration_tls_get_creds
  2020-07-22  3:32 [PATCH v1] migration: tls: fix memory leak in migration_tls_get_creds Zhenyu Ye
@ 2020-07-22  9:15 ` Daniel P. Berrangé
  2020-08-27 17:36 ` Dr. David Alan Gilbert
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel P. Berrangé @ 2020-07-22  9:15 UTC (permalink / raw)
  To: Zhenyu Ye; +Cc: xiexiangyou, zhengchuan, qemu-devel, dgilbert, quintela

On Wed, Jul 22, 2020 at 11:32:28AM +0800, Zhenyu Ye wrote:
> Currently migration_tls_get_creds() adds the reference of creds
> but there was no place to unref it.  So the OBJECT(creds) will
> never be freed and result in memory leak.
> 
> The leak stack:
> Direct leak of 104 byte(s) in 1 object(s) allocated from:
>     #0 0xffffa88bd20b in __interceptor_malloc (/usr/lib64/libasan.so.4+0xd320b)
>     #1 0xffffa7f0cb1b in g_malloc (/usr/lib64/libglib-2.0.so.0+0x58b1b)
>     #2 0x14b58cb in object_new_with_type qom/object.c:634
>     #3 0x14b597b in object_new qom/object.c:645
>     #4 0x14c0e4f in user_creatable_add_type qom/object_interfaces.c:59
>     #5 0x141c78b in qmp_object_add qom/qom-qmp-cmds.c:312
>     #6 0x140e513 in qmp_marshal_object_add qapi/qapi-commands-qom.c:279
>     #7 0x176ba97 in do_qmp_dispatch qapi/qmp-dispatch.c:165
>     #8 0x176bee7 in qmp_dispatch qapi/qmp-dispatch.c:208
>     #9 0x136e337 in monitor_qmp_dispatch monitor/qmp.c:150
>     #10 0x136eae3 in monitor_qmp_bh_dispatcher monitor/qmp.c:239
>     #11 0x1852e93 in aio_bh_call util/async.c:89
>     #12 0x18531b7 in aio_bh_poll util/async.c:117
>     #13 0x18616bf in aio_dispatch util/aio-posix.c:459
>     #14 0x1853f37 in aio_ctx_dispatch util/async.c:268
>     #15 0xffffa7f06a7b in g_main_context_dispatch (/usr/lib64/libglib-2.0.so.0+0x52a7b)
> 
> Since we're fine to use the borrowed reference when using the creds,
> so just remove the object_ref() in migration_tls_get_creds().
> 
> Signed-off-by: Zhenyu Ye <yezhenyu2@huawei.com>
> ---
>  migration/tls.c | 1 -
>  1 file changed, 1 deletion(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


> 
> diff --git a/migration/tls.c b/migration/tls.c
> index 5171afc6c4..7a02ec8656 100644
> --- a/migration/tls.c
> +++ b/migration/tls.c
> @@ -58,7 +58,6 @@ migration_tls_get_creds(MigrationState *s,
>          return NULL;
>      }
>  
> -    object_ref(OBJECT(ret));
>      return ret;
>  }
>  
> -- 
> 2.19.1
> 
> 

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



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

* Re: [PATCH v1] migration: tls: fix memory leak in migration_tls_get_creds
  2020-07-22  3:32 [PATCH v1] migration: tls: fix memory leak in migration_tls_get_creds Zhenyu Ye
  2020-07-22  9:15 ` Daniel P. Berrangé
@ 2020-08-27 17:36 ` Dr. David Alan Gilbert
  1 sibling, 0 replies; 3+ messages in thread
From: Dr. David Alan Gilbert @ 2020-08-27 17:36 UTC (permalink / raw)
  To: Zhenyu Ye; +Cc: zhengchuan, berrange, qemu-devel, xiexiangyou, quintela

* Zhenyu Ye (yezhenyu2@huawei.com) wrote:
> Currently migration_tls_get_creds() adds the reference of creds
> but there was no place to unref it.  So the OBJECT(creds) will
> never be freed and result in memory leak.
> 
> The leak stack:
> Direct leak of 104 byte(s) in 1 object(s) allocated from:
>     #0 0xffffa88bd20b in __interceptor_malloc (/usr/lib64/libasan.so.4+0xd320b)
>     #1 0xffffa7f0cb1b in g_malloc (/usr/lib64/libglib-2.0.so.0+0x58b1b)
>     #2 0x14b58cb in object_new_with_type qom/object.c:634
>     #3 0x14b597b in object_new qom/object.c:645
>     #4 0x14c0e4f in user_creatable_add_type qom/object_interfaces.c:59
>     #5 0x141c78b in qmp_object_add qom/qom-qmp-cmds.c:312
>     #6 0x140e513 in qmp_marshal_object_add qapi/qapi-commands-qom.c:279
>     #7 0x176ba97 in do_qmp_dispatch qapi/qmp-dispatch.c:165
>     #8 0x176bee7 in qmp_dispatch qapi/qmp-dispatch.c:208
>     #9 0x136e337 in monitor_qmp_dispatch monitor/qmp.c:150
>     #10 0x136eae3 in monitor_qmp_bh_dispatcher monitor/qmp.c:239
>     #11 0x1852e93 in aio_bh_call util/async.c:89
>     #12 0x18531b7 in aio_bh_poll util/async.c:117
>     #13 0x18616bf in aio_dispatch util/aio-posix.c:459
>     #14 0x1853f37 in aio_ctx_dispatch util/async.c:268
>     #15 0xffffa7f06a7b in g_main_context_dispatch (/usr/lib64/libglib-2.0.so.0+0x52a7b)
> 
> Since we're fine to use the borrowed reference when using the creds,
> so just remove the object_ref() in migration_tls_get_creds().
> 
> Signed-off-by: Zhenyu Ye <yezhenyu2@huawei.com>

Queued, sorry for the delay.

> ---
>  migration/tls.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/migration/tls.c b/migration/tls.c
> index 5171afc6c4..7a02ec8656 100644
> --- a/migration/tls.c
> +++ b/migration/tls.c
> @@ -58,7 +58,6 @@ migration_tls_get_creds(MigrationState *s,
>          return NULL;
>      }
>  
> -    object_ref(OBJECT(ret));
>      return ret;
>  }
>  
> -- 
> 2.19.1
> 
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



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

end of thread, other threads:[~2020-08-27 17:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-22  3:32 [PATCH v1] migration: tls: fix memory leak in migration_tls_get_creds Zhenyu Ye
2020-07-22  9:15 ` Daniel P. Berrangé
2020-08-27 17:36 ` Dr. David Alan Gilbert

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).