diff options
author | Tim Deegan <tim@xen.org> | 2013-02-15 09:42:02 +0100 |
---|---|---|
committer | Tim Deegan <tim@xen.org> | 2013-02-15 09:42:02 +0100 |
commit | 085f1f2d3aee1a35dfc7ca2f4423e51fa654010c (patch) | |
tree | b51477e5ed0cbb7828cc01f2fe5ad95c2fc83731 /xen/common/xenoprof.c | |
parent | 63a47721ad3f2bbeedf80850728c9a4aff0224ae (diff) | |
download | xen-085f1f2d3aee1a35dfc7ca2f4423e51fa654010c.tar.gz xen-085f1f2d3aee1a35dfc7ca2f4423e51fa654010c.tar.bz2 xen-085f1f2d3aee1a35dfc7ca2f4423e51fa654010c.zip |
xenoprof: avoid division by 0
Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Jan Beulich <jbeulich@suse.com>
Diffstat (limited to 'xen/common/xenoprof.c')
-rw-r--r-- | xen/common/xenoprof.c | 11 |
1 files 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 |