From 085f1f2d3aee1a35dfc7ca2f4423e51fa654010c Mon Sep 17 00:00:00 2001 From: Tim Deegan Date: Fri, 15 Feb 2013 09:42:02 +0100 Subject: [PATCH] xenoprof: avoid division by 0 Signed-off-by: Tim Deegan Acked-by: Jan Beulich Acked-by: Keir Fraser Committed-by: Jan Beulich --- xen/common/xenoprof.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/xen/common/xenoprof.c b/xen/common/xenoprof.c index 220f1c7785..03ec614f58 100644 --- a/xen/common/xenoprof.c +++ b/xen/common/xenoprof.c @@ -193,6 +193,13 @@ static int alloc_xenoprof_struct( unsigned max_max_samples; int i; + nvcpu = 0; + for_each_vcpu ( d, v ) + nvcpu++; + + if ( !nvcpu ) + return -EINVAL; + d->xenoprof = xzalloc(struct xenoprof); if ( d->xenoprof == NULL ) { @@ -209,10 +216,6 @@ static int alloc_xenoprof_struct( return -ENOMEM; } - nvcpu = 0; - for_each_vcpu ( d, v ) - nvcpu++; - bufsize = sizeof(struct xenoprof_buf); i = sizeof(struct event_log); #ifdef CONFIG_COMPAT -- 2.30.2