diff options
-rw-r--r-- | hdata/memory.c | 14 | ||||
-rw-r--r-- | hdata/spira.h | 3 |
2 files changed, 7 insertions, 10 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)); diff --git a/hdata/spira.h b/hdata/spira.h index ef2aec2..476cfba 100644 --- a/hdata/spira.h +++ b/hdata/spira.h @@ -541,6 +541,7 @@ struct msvpd_trace { /* Idata index 5: Hostboot reserved memory address range */ #define MSVPD_IDATA_HB_RESERVED_MEM 5 +#define HB_RESERVE_MEM_LABEL_SIZE 64 struct msvpd_hb_reserved_mem { #define MSVPD_HBRMEM_RANGE_TYPE PPC_BITMASK32(0,7) #define HBRMEM_CONTAINER_VERIFICATION_CODE 0x3 @@ -548,7 +549,7 @@ struct msvpd_hb_reserved_mem { __be64 start_addr; __be64 end_addr; __be32 label_size; - uint8_t label[64]; + uint8_t label[HB_RESERVE_MEM_LABEL_SIZE]; uint8_t rw_perms; #define HB_RESERVE_READABLE 0x80 #define HB_RESERVE_WRITEABLE 0x40 |