libvchan: Fix cleanup when xc_gntshr_open failed
authorMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Wed, 26 Jul 2017 21:27:14 +0000 (23:27 +0200)
committerWei Liu <wei.liu2@citrix.com>
Fri, 28 Jul 2017 16:46:14 +0000 (17:46 +0100)
If xc_gntshr_open failed the only thing to cleanup is free allocated
memory. So instead of calling libxenvchan_close (which assume
valid calculated buffers being mmaped already) free memory and return.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/libvchan/init.c

index 83e1deec44b692988c375f76aac7f907af29ce8f..e53f3a78d20790e5f97da557667d2a3bc2955dee 100644 (file)
@@ -329,8 +329,10 @@ struct libxenvchan *libxenvchan_server_init(struct xentoollog_logger *logger,
        }
 
        ctrl->gntshr = xengntshr_open(logger, 0);
-       if (!ctrl->gntshr)
-               goto out;
+       if (!ctrl->gntshr) {
+               free(ctrl);
+               return 0;
+       }
 
        if (init_evt_srv(ctrl, domain, logger))
                goto out;