diff mbox series

[2/3] qtest: fix qtest_qmp_device_add leak

Message ID 20191107192731.17330-3-marcandre.lureau@redhat.com (mailing list archive)
State New, archived
Headers show
Series Some memory leak fixes | expand

Commit Message

Marc-André Lureau Nov. 7, 2019, 7:27 p.m. UTC
Spotted by ASAN.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 tests/libqtest.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Laurent Vivier Nov. 7, 2019, 8:31 p.m. UTC | #1
On 07/11/2019 20:27, Marc-André Lureau wrote:
> Spotted by ASAN.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  tests/libqtest.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tests/libqtest.c b/tests/libqtest.c
> index 3706bccd8d..91e9cb220c 100644
> --- a/tests/libqtest.c
> +++ b/tests/libqtest.c
> @@ -1274,6 +1274,7 @@ void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id,
>      qdict_put_str(args, "id", id);
>  
>      qtest_qmp_device_add_qdict(qts, driver, args);
> +    qobject_unref(args);
>  }
>  
>  static void device_deleted_cb(void *opaque, const char *name, QDict *data)
> 

Stupid question: where is the qobject_ref()?

Thanks,
Laurent
Marc-André Lureau Nov. 7, 2019, 8:41 p.m. UTC | #2
Hi

On Fri, Nov 8, 2019 at 12:31 AM Laurent Vivier <lvivier@redhat.com> wrote:
>
> On 07/11/2019 20:27, Marc-André Lureau wrote:
> > Spotted by ASAN.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >  tests/libqtest.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/tests/libqtest.c b/tests/libqtest.c
> > index 3706bccd8d..91e9cb220c 100644
> > --- a/tests/libqtest.c
> > +++ b/tests/libqtest.c
> > @@ -1274,6 +1274,7 @@ void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id,
> >      qdict_put_str(args, "id", id);
> >
> >      qtest_qmp_device_add_qdict(qts, driver, args);
> > +    qobject_unref(args);
> >  }
> >
> >  static void device_deleted_cb(void *opaque, const char *name, QDict *data)
> >
>
> Stupid question: where is the qobject_ref()?

The initial ref is from qobject_from_vjsonf_nofail() constructor
Thomas Huth Nov. 8, 2019, 9:54 a.m. UTC | #3
On 07/11/2019 20.27, Marc-André Lureau wrote:
> Spotted by ASAN.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>   tests/libqtest.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/tests/libqtest.c b/tests/libqtest.c
> index 3706bccd8d..91e9cb220c 100644
> --- a/tests/libqtest.c
> +++ b/tests/libqtest.c
> @@ -1274,6 +1274,7 @@ void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id,
>       qdict_put_str(args, "id", id);
>   
>       qtest_qmp_device_add_qdict(qts, driver, args);
> +    qobject_unref(args);
>   }
>   
>   static void device_deleted_cb(void *opaque, const char *name, QDict *data)
> 

Fixes: b4510bb4109f5f ("tests: add qtest_qmp_device_add_qdict() helper")

Reviewed-by: Thomas Huth <thuth@redhat.com>

I can queue this via the qtest tree if nobody else wants to take it.
diff mbox series

Patch

diff --git a/tests/libqtest.c b/tests/libqtest.c
index 3706bccd8d..91e9cb220c 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -1274,6 +1274,7 @@  void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id,
     qdict_put_str(args, "id", id);
 
     qtest_qmp_device_add_qdict(qts, driver, args);
+    qobject_unref(args);
 }
 
 static void device_deleted_cb(void *opaque, const char *name, QDict *data)