From: "Jan Beulich" Subject: Re: [PATCH] xen/xenoprof: avoid division by 0 Date: Fri, 15 Feb 2013 08:10:07 +0000 Message-ID: <511DFB6F02000078000BE94E@nat28.tlf.novell.com> References: <68308aac7872c07631cb.1360858593@whitby.uk.xensource.com> <511D202E02000078000BE68A@nat28.tlf.novell.com> <20130214165003.GR83752@ocelot.phlegethon.org> <511D276A02000078000BE73D@nat28.tlf.novell.com> <20130214171004.GS83752@ocelot.phlegethon.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20130214171004.GS83752@ocelot.phlegethon.org> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Tim Deegan Cc: xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org >>> On 14.02.13 at 18:10, Tim Deegan wrote: > # HG changeset patch > # Parent 5a84cc531072378e6e5ff89b4c0e9a35000dc56f > xen/xenoprof: avoid division by 0. > > Signed-off-by: Tim Deegan Acked-by: Jan Beulich > diff -r 5a84cc531072 xen/common/xenoprof.c > --- a/xen/common/xenoprof.c Thu Feb 14 15:46:56 2013 +0000 > +++ b/xen/common/xenoprof.c Thu Feb 14 17:07:41 2013 +0000 > @@ -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