summaryrefslogtreecommitdiffstats
path: root/external
diff options
context:
space:
mode:
authorCyril Bur <cyril.bur@au1.ibm.com>2018-03-15 16:58:23 +1100
committerStewart Smith <stewart@linux.ibm.com>2018-04-09 03:45:23 -0500
commit79316cb6aca6fc79585f4f47c18a37f2eb177780 (patch)
treec228abad78786db2ac503444a56eec0467b089e8 /external
parent3d47dbb4fb8dc010c1905a878794731e812a05ac (diff)
downloadblackbird-skiboot-79316cb6aca6fc79585f4f47c18a37f2eb177780.tar.gz
blackbird-skiboot-79316cb6aca6fc79585f4f47c18a37f2eb177780.zip
libflash/libffs: Refcount ffs entries
Currently consumers can add an new ffs entry to multiple headers, this is fine but freeing any of the headers will cause the entry to be freed, this causes double free problems. Even if only one header is uses, the consumer of the library still has a reference to the entry, which they may well reuse at some other point. libffs will now refcount entries and only free when there are no more references. This patch also removes the pointless return value of ffs_hdr_free() Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
Diffstat (limited to 'external')
-rw-r--r--external/ffspart/ffspart.c2
-rw-r--r--external/pflash/pflash.c2
2 files changed, 3 insertions, 1 deletions
diff --git a/external/ffspart/ffspart.c b/external/ffspart/ffspart.c
index 04de6b6d..fd5075d5 100644
--- a/external/ffspart/ffspart.c
+++ b/external/ffspart/ffspart.c
@@ -344,7 +344,7 @@ out_if:
continue;
out_while:
- free(new_entry);
+ ffs_entry_put(new_entry);
goto out_close_bl;
}
diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c
index 3bc84758..72b90fc8 100644
--- a/external/pflash/pflash.c
+++ b/external/pflash/pflash.c
@@ -116,6 +116,7 @@ static uint32_t print_ffs_info(struct ffs_handle *ffsh, uint32_t toc)
}
user = ffs_entry_user_get(ent);
+ ffs_entry_put(ent);
flags = ffs_entry_user_to_string(&user);
if (!flags)
goto out;
@@ -589,6 +590,7 @@ static void print_partition_detail(struct ffs_handle *ffsh, uint32_t part_id)
"REPROVISION [F]\n" : "",
has_flag(ent, FFS_MISCFLAGS_VOLATILE) ? "VOLATILE [V]\n" : "",
has_flag(ent, FFS_MISCFLAGS_CLEARECC) ? "CLEARECC [C]\n" : "");
+ ffs_entry_put(ent);
if (l < 0) {
fprintf(stderr, "Memory allocation failure printing flags!\n");
goto out;
OpenPOWER on IntegriCloud