diff mbox

9pfs: adjust the order of resource cleanup in device unrealize

Message ID 582a6738.968c6b0a.ad67a.9505@mx.google.com
State New
Headers show

Commit Message

Li Qiang Nov. 15, 2016, 1:38 a.m. UTC
From: Li Qiang <liq3ea@gmail.com>

Unrealize should undo things that were set during realize in
reverse order. This is what this patch does.

Signed-off-by: Li Qiang <liq3ea@gmail.com>
---
 hw/9pfs/9p.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Greg Kurz Nov. 15, 2016, 10:15 a.m. UTC | #1
Hi Li,

Please incorporate this patch in your cleanup series since it depends on it.

On Mon, 14 Nov 2016 20:38:57 -0500
Li Qiang <liq3ea@gmail.com> wrote:

> From: Li Qiang <liq3ea@gmail.com>
> 
> Unrealize should undo things that were set during realize in
> reverse order. This is what this patch does.
> 

So should do the error path in realize actually. :)

> Signed-off-by: Li Qiang <liq3ea@gmail.com>
> ---
>  hw/9pfs/9p.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> index aea7e9d..f7e14ac 100644
> --- a/hw/9pfs/9p.c
> +++ b/hw/9pfs/9p.c
> @@ -3530,8 +3530,8 @@ out:
>  
>  void v9fs_device_unrealize_common(V9fsState *s, Error **errp)
>  {
> -    g_free(s->ctx.fs_root);
>      g_free(s->tag);
> +    g_free(s->ctx.fs_root);
>  }
>  
>  typedef struct VirtfsCoResetData {
diff mbox

Patch

diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index aea7e9d..f7e14ac 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -3530,8 +3530,8 @@  out:
 
 void v9fs_device_unrealize_common(V9fsState *s, Error **errp)
 {
-    g_free(s->ctx.fs_root);
     g_free(s->tag);
+    g_free(s->ctx.fs_root);
 }
 
 typedef struct VirtfsCoResetData {