aboutsummaryrefslogtreecommitdiff
path: root/hdata/memory.c
diff options
context:
space:
mode:
authorVasant Hegde <hegdevasant@linux.vnet.ibm.com>2018-09-07 10:46:54 +0530
committerStewart Smith <stewart@linux.vnet.ibm.com>2018-09-13 15:20:01 +1000
commit70a7a3fdfa36c2e105fd02061d4f440d22f99d7a (patch)
tree929dcbe0c358ef1fa1fd50dd7c992b3023d0558f /hdata/memory.c
parent2fba868b53809431df97e31ab728c85b0312ef06 (diff)
downloadskiboot-70a7a3fdfa36c2e105fd02061d4f440d22f99d7a.zip
skiboot-70a7a3fdfa36c2e105fd02061d4f440d22f99d7a.tar.gz
skiboot-70a7a3fdfa36c2e105fd02061d4f440d22f99d7a.tar.bz2
hdata: Cleanup get_hb_reserved_mem
- Use macro for label size - Replace malloc with array Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Reviewed-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'hdata/memory.c')
-rw-r--r--hdata/memory.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/hdata/memory.c b/hdata/memory.c
index 72a72e1..c922260 100644
--- a/hdata/memory.c
+++ b/hdata/memory.c
@@ -598,7 +598,7 @@ static void get_hb_reserved_mem(struct HDIF_common_hdr *ms_vpd)
u64 start_addr, end_addr, label_size;
struct dt_node *node;
int count, i;
- char *label;
+ char label[HB_RESERVE_MEM_LABEL_SIZE + 1];
/*
* XXX: Reservation names only exist on P9 and on P7/8 we get the
@@ -642,20 +642,16 @@ static void get_hb_reserved_mem(struct HDIF_common_hdr *ms_vpd)
/* remove the HRMOR bypass bit */
start_addr &= ~HRMOR_BIT;
end_addr &= ~HRMOR_BIT;
- if (label_size > 64)
- label_size = 64;
-
- label = malloc(label_size+1);
- assert(label);
+ if (label_size > HB_RESERVE_MEM_LABEL_SIZE)
+ label_size = HB_RESERVE_MEM_LABEL_SIZE;
+ memset(label, 0, HB_RESERVE_MEM_LABEL_SIZE + 1);
memcpy(label, hb_resv_mem->label, label_size);
label[label_size] = '\0';
/* Unnamed reservations are always broken. Ignore them. */
- if (strlen(label) == 0) {
- free(label);
+ if (strlen(label) == 0)
continue;
- }
prlog(PR_DEBUG, "MEM: Reserve '%s' %#" PRIx64 "-%#" PRIx64 " (type/inst=0x%08x)\n",
label, start_addr, end_addr, be32_to_cpu(hb_resv_mem->type_instance));