Skip to contentSkip to conversation

libxc: Free logger after printing error message

PATCH In review Jason Andryuk 2 participants 4 messages May 16, 2014 – May 22, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxc: Free logger after printing error message

On error, PERROR calls the already destroyed logger, which can segfault. Re-order the calls, so the logger is still available.

---
 tools/libxc/xc_private.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/libxc/xc_private.c +3 -3
index 0e18892..10e7e20 100644
@@ -201,14 +201,14 @@ static int xc_interface_close_common(xc_interface *xch)
     if (!xch)
 	return 0;
 
+    rc = xch->ops->close(xch, xch->ops_handle);
+    if (rc) PERROR("Could not close hypervisor interface");
+
     xc__hypercall_buffer_cache_release(xch);
 
     xtl_logger_destroy(xch->dombuild_logger_tofree);
     xtl_logger_destroy(xch->error_handler_tofree);
 
-    rc = xch->ops->close(xch, xch->ops_handle);
-    if (rc) PERROR("Could not close hypervisor interface");
-
     free(xch);
     return rc;
 }
Signature · 1 line
1.8.3.1
#2 lore raw
In reply to Jason Andryuk

Jason Andryuk writes ("[PATCH] libxc: Free logger after printing error message"):

Quoted 2 lines

On error, PERROR calls the already destroyed logger, which can segfault. Re-order the calls, so the logger is still available.

I have also added this to my list of patches to be backported.

Thanks,
Ian.

#3 lore raw

Ian Jackson writes ("Re: [PATCH] libxc: Free logger after printing error message"):

Quoted 5 lines

Jason Andryuk writes ("[PATCH] libxc: Free logger after printing error message"):

Quoted 2 lines

On error, PERROR calls the already destroyed logger, which can segfault. Re-order the calls, so the logger is still available.

I have also added this to my list of patches to be backported.

Now backported to 4.4 and will be pushed there shortly. It's inapplicable to 4.3.

Thanks,
Ian.