Skip to contentSkip to conversation

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

PATCH In review Julien Grall 3 participants 3 messages Dec 8, 2013 – Dec 9, 2013

lore
Share & tools
lore
#0 lore raw

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

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.

---
 xen/arch/arm/domain.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/domain.c +1 -1
index 52d2403..67c65c3 100644
@@ -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;
 
Signature · 1 line
1.7.10.4
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Julien Grall

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.

Quoted 22 lines
 xen/arch/arm/domain.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/domain.c +1 -1
index 52d2403..67c65c3 100644
@@ -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;
 
Signature · 1 line
1.7.10.4