[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [PATCH 2/2] lib/ukalloc: Add assertion to page allocator compatibility wrapper



uk_get_real_start() is used by the compatibility wrapper
to figure out the address of meta information. This patch
adds an assertion that checks that the meta information pointer
will never be 0x0.

Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
---
 lib/ukalloc/alloc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/ukalloc/alloc.c b/lib/ukalloc/alloc.c
index cf378d0..8a19421 100644
--- a/lib/ukalloc/alloc.c
+++ b/lib/ukalloc/alloc.c
@@ -114,6 +114,12 @@ static void *uk_get_real_start(const void *ptr)
 {
        void *intptr;
 
+       /* a ptr less or equal to page size
+        * would mean that the actual allocated
+        * object started at 0x0, so it was NULL
+        */
+       UK_ASSERT((uintptr_t) ptr > __PAGE_SIZE);
+
        intptr = (void *) ALIGN_DOWN((uintptr_t) ptr,
                                     (uintptr_t) __PAGE_SIZE);
        if (intptr == ptr) {
-- 
2.7.4


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.