diff mbox

xen/arm: arch_domain_create: don't return 0 when alloc_xenheap_pages has failed

Message ID 1386469952-21744-1-git-send-email-julien.grall@linaro.org
State Accepted
Headers show

Commit Message

Julien Grall Dec. 8, 2013, 2:32 a.m. UTC
The previous call before alloc_xenheap_pages reset rc to 0 if it success.
If the latter fails, arch_domain_create will return 0 and Xen will consider
the domain as valid. Move rc initialization later.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
---
 xen/arch/arm/domain.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefano Stabellini Dec. 8, 2013, 3:15 p.m. UTC | #1
On Sun, 8 Dec 2013, Julien Grall wrote:
> The previous call before alloc_xenheap_pages reset rc to 0 if it success.
> If the latter fails, arch_domain_create will return 0 and Xen will consider
> the domain as valid. Move rc initialization later.
> 
> Signed-off-by: Julien Grall <julien.grall@linaro.org>


Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>


>  xen/arch/arm/domain.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
> index 52d2403..67c65c3 100644
> --- a/xen/arch/arm/domain.c
> +++ b/xen/arch/arm/domain.c
> @@ -501,10 +501,10 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags)
>      if ( is_idle_domain(d) )
>          return 0;
>  
> -    rc = -ENOMEM;
>      if ( (rc = p2m_init(d)) != 0 )
>          goto fail;
>  
> +    rc = -ENOMEM;
>      if ( (d->shared_info = alloc_xenheap_pages(0, 0)) == NULL )
>          goto fail;
>  
> -- 
> 1.7.10.4
>
Ian Campbell Dec. 9, 2013, 10:19 a.m. UTC | #2
On Sun, 2013-12-08 at 15:15 +0000, Stefano Stabellini wrote:
> On Sun, 8 Dec 2013, Julien Grall wrote:
> > The previous call before alloc_xenheap_pages reset rc to 0 if it success.
> > If the latter fails, arch_domain_create will return 0 and Xen will consider
> > the domain as valid. Move rc initialization later.
> > 
> > Signed-off-by: Julien Grall <julien.grall@linaro.org>
> 
> 
> Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

+ applied, thanks.

Ian.
diff mbox

Patch

diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 52d2403..67c65c3 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -501,10 +501,10 @@  int arch_domain_create(struct domain *d, unsigned int domcr_flags)
     if ( is_idle_domain(d) )
         return 0;
 
-    rc = -ENOMEM;
     if ( (rc = p2m_init(d)) != 0 )
         goto fail;
 
+    rc = -ENOMEM;
     if ( (d->shared_info = alloc_xenheap_pages(0, 0)) == NULL )
         goto fail;