All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ocaml/xenctrl: Check return values from hypercalls
@ 2015-01-27 20:38 Andrew Cooper
  2015-01-28  9:35 ` Dave Scott
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cooper @ 2015-01-27 20:38 UTC (permalink / raw)
  To: Xen-devel; +Cc: Andrew Cooper, Dave Scott, Ian Jackson, Ian Campbell, Wei Liu

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>

---
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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ocaml/xenctrl: Check return values from hypercalls
  2015-01-27 20:38 [PATCH] ocaml/xenctrl: Check return values from hypercalls Andrew Cooper
@ 2015-01-28  9:35 ` Dave Scott
  2015-01-28 14:05   ` Ian Campbell
  0 siblings, 1 reply; 3+ messages in thread
From: Dave Scott @ 2015-01-28  9:35 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Ian Jackson, Dave Scott, Wei Liu, Ian Campbell, Xen-devel

Looks fine to me

Acked-by: David Scott <dave.scott@citrix.com>

> On 27 Jan 2015, at 20:38, Andrew Cooper <andrew.cooper3@citrix.com> wrote:
> 
> 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>
> 
> ---
> 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
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ocaml/xenctrl: Check return values from hypercalls
  2015-01-28  9:35 ` Dave Scott
@ 2015-01-28 14:05   ` Ian Campbell
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Campbell @ 2015-01-28 14:05 UTC (permalink / raw)
  To: Dave Scott; +Cc: Andrew Cooper, Ian Jackson, Wei Liu, Xen-devel

On Wed, 2015-01-28 at 09:35 +0000, Dave Scott wrote:
> Looks fine to me
> 
> Acked-by: David Scott <dave.scott@citrix.com>

applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-01-28 14:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-27 20:38 [PATCH] ocaml/xenctrl: Check return values from hypercalls Andrew Cooper
2015-01-28  9:35 ` Dave Scott
2015-01-28 14:05   ` Ian Campbell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.