* [PATCH] xen/arm: Directly return NULL if Xen fails to allocate domain struct
@ 2014-01-31 22:22 Julien Grall
2014-02-04 15:50 ` Ian Campbell
0 siblings, 1 reply; 2+ messages in thread
From: Julien Grall @ 2014-01-31 22:22 UTC (permalink / raw)
To: xen-devel; +Cc: stefano.stabellini, Julien Grall, tim, ian.campbell, patches
The current implementation of alloc_domain_struct, dereference the newly
allocated pointer even if the allocation has failed.
Signed-off-by: Julien Grall <julien.grall@linaro.org>
---
This is a bug fix for Xen 4.4. Without this patch if Xen run out of
memory, it will segfault because it's trying to dereference a NULL
pointer.
---
xen/arch/arm/domain.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 635a9a4..c279a27 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -409,8 +409,10 @@ struct domain *alloc_domain_struct(void)
struct domain *d;
BUILD_BUG_ON(sizeof(*d) > PAGE_SIZE);
d = alloc_xenheap_pages(0, 0);
- if ( d != NULL )
- clear_page(d);
+ if ( d == NULL )
+ return NULL;
+
+ clear_page(d);
d->arch.grant_table_gpfn = xmalloc_array(xen_pfn_t, max_nr_grant_frames);
return d;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] xen/arm: Directly return NULL if Xen fails to allocate domain struct
2014-01-31 22:22 [PATCH] xen/arm: Directly return NULL if Xen fails to allocate domain struct Julien Grall
@ 2014-02-04 15:50 ` Ian Campbell
0 siblings, 0 replies; 2+ messages in thread
From: Ian Campbell @ 2014-02-04 15:50 UTC (permalink / raw)
To: Julien Grall; +Cc: xen-devel, tim, stefano.stabellini, patches
On Fri, 2014-01-31 at 22:22 +0000, Julien Grall wrote:
> The current implementation of alloc_domain_struct, dereference the newly
> allocated pointer even if the allocation has failed.
>
> Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked + applied. thanks.
>
> ---
>
> This is a bug fix for Xen 4.4. Without this patch if Xen run out of
> memory, it will segfault because it's trying to dereference a NULL
> pointer.
In general you need to CC George for this sort of thing. I've applied it
this time since I think it is an uncontroversial fix.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-02-04 15:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-31 22:22 [PATCH] xen/arm: Directly return NULL if Xen fails to allocate domain struct Julien Grall
2014-02-04 15:50 ` Ian Campbell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).