# HG changeset patch # User Tim Deegan # Date 1360917722 -3600 # Node ID 0cca8a18432f08b342d76a753aa98559d892f592 # Parent 7af3c38ae187b351c5cea58e9eee482b50d814d8 xenoprof: avoid division by 0 Signed-off-by: Tim Deegan Acked-by: Jan Beulich Acked-by: Keir Fraser Committed-by: Jan Beulich --- 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