diff options
author | Vasant Hegde <hegdevasant@linux.vnet.ibm.com> | 2018-09-07 10:46:54 +0530 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2018-09-13 15:20:01 +1000 |
commit | 70a7a3fdfa36c2e105fd02061d4f440d22f99d7a (patch) | |
tree | 929dcbe0c358ef1fa1fd50dd7c992b3023d0558f /hdata | |
parent | 2fba868b53809431df97e31ab728c85b0312ef06 (diff) | |
download | blackbird-skiboot-70a7a3fdfa36c2e105fd02061d4f440d22f99d7a.tar.gz blackbird-skiboot-70a7a3fdfa36c2e105fd02061d4f440d22f99d7a.zip |
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')
-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 72a72e11..c9222605 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 ef2aec25..476cfba1 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 |