Skip to content

Commit

Permalink
libflash/libffs: ffs_close() should use ffs_hdr_free()
Browse files Browse the repository at this point in the history
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
  • Loading branch information
cyrilbur-ibm authored and stewartsmith committed Apr 9, 2018
1 parent 07426f4 commit 6d2ba68
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions libflash/libffs.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,14 +440,32 @@ int ffs_init(uint32_t offset, uint32_t max_size, struct blocklevel_device *bl,
return rc;
}

void ffs_close(struct ffs_handle *ffs)
static void __hdr_free(struct ffs_hdr *hdr)
{
struct ffs_entry *ent, *next;

list_for_each_safe(&ffs->hdr.entries, ent, next, list) {
list_for_each_safe(&hdr->entries, ent, next, list) {
list_del(&ent->list);
free(ent);
}
if (hdr->side) {
hdr->side->side = NULL;
ffs_hdr_free(hdr->side);
}
}

int ffs_hdr_free(struct ffs_hdr *hdr)
{
printf("Freeing hdr\n");
__hdr_free(hdr);
free(hdr);

return 0;
}

void ffs_close(struct ffs_handle *ffs)
{
__hdr_free(&ffs->hdr);

if (ffs->cache)
free(ffs->cache);
Expand Down Expand Up @@ -903,24 +921,6 @@ int ffs_hdr_new(uint32_t block_size, uint32_t block_count, struct ffs_hdr **r)
return 0;
}

int ffs_hdr_free(struct ffs_hdr *hdr)
{
struct ffs_entry *ent, *next;

printf("Freeing hdr\n");
list_for_each_safe(&hdr->entries, ent, next, list) {
list_del(&ent->list);
free(ent);
}
if (hdr->side) {
hdr->side->side = NULL;
ffs_hdr_free(hdr->side);
}
free(hdr);

return 0;
}

int ffs_update_act_size(struct ffs_handle *ffs, uint32_t part_idx,
uint32_t act_size)
{
Expand Down

0 comments on commit 6d2ba68

Please sign in to comment.