pmalloc: correct format_pmalloc_map u32 index overrun bug
Change-Id: I95ba4eab6e2154ef33a479450b997c8317db3a92
Signed-off-by: Kingwel Xie <kingwel.xie@ericsson.com>
diff --git a/src/vppinfra/pmalloc.c b/src/vppinfra/pmalloc.c
index b707336..e903511 100644
--- a/src/vppinfra/pmalloc.c
+++ b/src/vppinfra/pmalloc.c
@@ -359,7 +359,6 @@
pp->n_free_blocks = 1 << (pm->def_log2_page_sz - PMALLOC_LOG2_BLOCK_SZ);
pp->index = pp - pm->pages;
pp->arena_index = a->index;
- pp->pa = (uword) va + (1 << pm->def_log2_page_sz) * i;
vec_add1 (a->page_indices, pp->index);
a->n_pages++;
}
@@ -608,8 +607,6 @@
int verbose = va_arg (*va, int);
u32 indent = format_get_indent (s);
- s = format (s, "page %u: phys-addr %p ", pp->index, pp->pa);
-
if (pp->chunks == 0)
return s;
@@ -699,7 +696,9 @@
{
uword *lookup_val, pa, va;
lookup_val = vec_elt_at_index (pm->lookup_table, index);
- va = pointer_to_uword (pm->base) + (index << pm->lookup_log2_page_sz);
+ va =
+ pointer_to_uword (pm->base) +
+ ((uword) index << pm->lookup_log2_page_sz);
pa = va - *lookup_val;
s =
format (s, "\n %16p %13p %8U", uword_to_pointer (va, u64),
diff --git a/src/vppinfra/pmalloc.h b/src/vppinfra/pmalloc.h
index eae317f..25c4678 100644
--- a/src/vppinfra/pmalloc.h
+++ b/src/vppinfra/pmalloc.h
@@ -36,7 +36,6 @@
{
u32 index;
u32 arena_index;
- uword pa;
clib_pmalloc_chunk_t *chunks;
u32 first_chunk_index;
u32 n_free_chunks;