From: Tim Deegan Date: Fri, 15 Feb 2013 08:42:02 +0000 (+0100) Subject: xenoprof: avoid division by 0 X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~7291 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=085f1f2d3aee1a35dfc7ca2f4423e51fa654010c;p=xen.git xenoprof: avoid division by 0 Signed-off-by: Tim Deegan Acked-by: Jan Beulich Acked-by: Keir Fraser Committed-by: Jan Beulich --- 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