]> xenbits.xensource.com Git - people/tklengyel/xen.git/commitdiff
tools/xenstore-control: Don't leak buf in live_update_start()
authorJulien Grall <jgrall@amazon.com>
Thu, 25 Feb 2021 17:08:49 +0000 (17:08 +0000)
committerJulien Grall <jgrall@amazon.com>
Fri, 26 Feb 2021 09:46:36 +0000 (09:46 +0000)
All the error paths but one will free buf. Cover the remaining path so
buf can't be leaked.

This bug was discovered and resolved using Coverity Static Analysis
Security Testing (SAST) by Synopsys, Inc.

Fixes: 7f97193e6aa8 ("tools/xenstore: add live update command to xenstore-control")
Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
tools/xenstore/xenstore_control.c

index f6f4626c06568b5d33abab2ee184111083aaaccd..548363ee709473e1aa889c18c1f89406c91a3b61 100644 (file)
@@ -44,8 +44,10 @@ static int live_update_start(struct xs_handle *xsh, bool force, unsigned int to)
         return 1;
 
     ret = strdup("BUSY");
-    if (!ret)
+    if (!ret) {
+        free(buf);
         return 1;
+    }
 
     for (time_start = time(NULL); time(NULL) - time_start < to;) {
         free(ret);