]> xenbits.xensource.com Git - xen.git/commitdiff
ocaml/xenctrl: Check return values from hypercalls
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 27 Jan 2015 20:38:11 +0000 (20:38 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Wed, 12 Aug 2015 10:57:18 +0000 (11:57 +0100)
rather than blindly continuing and possibly using negative values.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Dave Scott <dave.scott@eu.citrix.com>
Acked-by: David Scott <dave.scott@citrix.com>
(cherry picked from commit 3380f5b6270e6fa4b24313f8808e7625e4c5a6ba)
(cherry picked from commit c91ed889ea3c3781a94a30909f30c3aad56c97d5)
(cherry picked from commit 10a95535b0dcde7daa3402b92f3c8d4494781c28)

tools/ocaml/libs/xc/xenctrl_stubs.c

index f5cf0edb241c61f09542c0a579fe47b95ed05722..c27c897e668db08cf7cfdd6058e3f8ba27bfe0f9 100644 (file)
@@ -455,6 +455,9 @@ CAMLprim value stub_xc_vcpu_getaffinity(value xch, value domid,
        int i, len = xc_get_max_cpus(_H(xch));
        int retval;
 
+       if (len < 1)
+               failwith_xc(_H(xch));
+
        c_cpumap = xc_cpumap_alloc(_H(xch));
        if (c_cpumap == NULL)
                failwith_xc(_H(xch));
@@ -805,6 +808,12 @@ CAMLprim value stub_xc_version_version(value xch)
 
        caml_enter_blocking_section();
        packed = xc_version(_H(xch), XENVER_version, NULL);
+       caml_leave_blocking_section();
+
+       if (packed < 0)
+               failwith_xc(_H(xch));
+
+       caml_enter_blocking_section();
        retval = xc_version(_H(xch), XENVER_extraversion, &extra);
        caml_leave_blocking_section();