From: Dave Scott Subject: Re: [PATCH] ocaml/xenctrl: Check return values from hypercalls Date: Wed, 28 Jan 2015 09:35:30 +0000 Message-ID: <6941D352-9429-4103-A230-F8914D95B155@citrix.com> References: <1422391091-6639-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1422391091-6639-1-git-send-email-andrew.cooper3@citrix.com> Content-Language: en-US Content-ID: <6AF635E3EE2FF648A43648DA178D6C93@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper Cc: Ian Jackson , Dave Scott , Wei Liu , Ian Campbell , Xen-devel List-Id: xen-devel@lists.xenproject.org Looks fine to me Acked-by: David Scott > On 27 Jan 2015, at 20:38, Andrew Cooper wrote: > > rather than blindly continuing and possibly using negative values. > > Signed-off-by: Andrew Cooper > CC: Ian Campbell > CC: Ian Jackson > CC: Wei Liu > CC: Dave Scott > > --- > Found with XenServers Coverity scanning. We have the sensitivity turned up > higher than Coverity Scan, which does not flag these issues. > --- > tools/ocaml/libs/xc/xenctrl_stubs.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenctrl_stubs.c > index f0810eb..92d064f 100644 > --- a/tools/ocaml/libs/xc/xenctrl_stubs.c > +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c > @@ -457,6 +457,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)); > @@ -821,6 +824,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(); > > -- > 1.7.10.4 >