[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 5/8] tools/ocaml: libxc: Check error return in stub_xc_vcpu_context_get()



From: Julien Grall <jgrall@xxxxxxxxxx>

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@xxxxxxxxxx>
---
 tools/ocaml/libs/xc/xenctrl_stubs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c 
b/tools/ocaml/libs/xc/xenctrl_stubs.c
index 904da45c4f..0fdbeac158 100644
--- a/tools/ocaml/libs/xc/xenctrl_stubs.c
+++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
@@ -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));
-- 
2.17.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.