tools/ocaml: libxc: Check error return in stub_xc_vcpu_context_get()
authorJulien Grall <jgrall@amazon.com>
Sun, 29 Mar 2020 19:12:34 +0000 (20:12 +0100)
committerJulien Grall <jgrall@amazon.com>
Mon, 20 Apr 2020 14:02:17 +0000 (15:02 +0100)
xc_vcpu_getcontext() may fail to retrieve the vcpu context. Rather than
ignoring the return value, check it and throw an error if needed.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
tools/ocaml/libs/xc/xenctrl_stubs.c

index 904da45c4fcf0a1ba1bce24fa557cdba0f158093..0fdbeac158b8f3133062cc876552cec51c52ef50 100644 (file)
@@ -497,6 +497,8 @@ CAMLprim value stub_xc_vcpu_context_get(value xch, value domid,
        vcpu_guest_context_any_t ctxt;
 
        ret = xc_vcpu_getcontext(_H(xch), _D(domid), Int_val(cpu), &ctxt);
+       if ( ret < 0 )
+               failwith_xc(_H(xch));
 
        context = caml_alloc_string(sizeof(ctxt));
        memcpy(String_val(context), (char *) &ctxt.c, sizeof(ctxt.c));