vchan-socket-proxy: Check xs_watch return value
authorJason Andryuk <jandryuk@gmail.com>
Thu, 11 Jun 2020 03:29:30 +0000 (23:29 -0400)
committerWei Liu <wl@xen.org>
Fri, 26 Jun 2020 11:59:46 +0000 (11:59 +0000)
Check the return value of xs_watch and error out on failure.

This was found by Citrix's Coverity.

Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
Acked-by: Wei Liu <wl@xen.org>
Reviewed-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Release-acked-by: Paul Durrant <paul@xen.org>
tools/libvchan/vchan-socket-proxy.c

index c6a83e47128f3f784c507680a54062c4b3958570..196f6016b9803f63bda535839ff3f724c6e37161 100644 (file)
@@ -232,8 +232,15 @@ static struct libxenvchan *connect_vchan(int domid, const char *path) {
         goto out;
     }
     /* wait for vchan server to create *path* */
-    xs_watch(xs, path, "path");
-    xs_watch(xs, "@releaseDomain", "release");
+    if (!xs_watch(xs, path, "path")) {
+        fprintf(stderr, "xs_watch(%s) failed.\n", path);
+        goto out;
+    }
+    if (!xs_watch(xs, "@releaseDomain", "release")) {
+        fprintf(stderr, "xs_watch(@releaseDomain failed.\n");
+        goto out;
+    }
+
     while ((watch_ret = xs_read_watch(xs, &watch_num))) {
         /* don't care about exact which fired the watch */
         free(watch_ret);