[Skiboot] [PATCH 1/2] hdata: Fix memory leak
Neelesh Gupta
neelegup at linux.vnet.ibm.com
Tue May 19 01:49:23 AEST 2015
Fix leak and avoid repeated call to the same function
Signed-off-by: Neelesh Gupta <neelegup at linux.vnet.ibm.com>
Reviewed-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
---
hdata/memory.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/hdata/memory.c b/hdata/memory.c
index 18beb3b..019e5fe 100644
--- a/hdata/memory.c
+++ b/hdata/memory.c
@@ -121,24 +121,26 @@ static bool add_address_range(struct dt_node *root,
size_t namesz = sizeof("memory@") + STR_MAX_CHARS(reg[0]);
name = (char*)malloc(namesz);
+ assert(name);
+
+ chip_id = pcid_to_chip_id(be32_to_cpu(arange->chip));
prlog(PR_DEBUG, " Range: 0x%016llx..0x%016llx "
"on Chip 0x%x mattr: 0x%x\n",
(long long)arange->start, (long long)arange->end,
- pcid_to_chip_id(arange->chip), arange->mirror_attr);
+ chip_id, arange->mirror_attr);
/* reg contains start and length */
reg[0] = cleanup_addr(be64_to_cpu(arange->start));
reg[1] = cleanup_addr(be64_to_cpu(arange->end)) - reg[0];
- chip_id = pcid_to_chip_id(be32_to_cpu(arange->chip));
-
if (be16_to_cpu(id->flags) & MS_AREA_SHARED) {
/* Only enter shared nodes once. */
mem = find_shared(root, be16_to_cpu(id->share_id),
reg[0], reg[1]);
if (mem) {
append_chip_id(mem, chip_id);
+ free(name);
return true;
}
}
More information about the Skiboot
mailing list