This patch is part of the qfw refactor work.
The qemu_fwcfg_free_files() function is only used in error handling in
ACPI table generation, let's not make this a core function and move it
to the right place.
Signed-off-by: Miao Yan <yanmiaobest@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
}
out:
- if (ret)
- qemu_fwcfg_free_files();
+ if (ret) {
+ struct fw_cfg_file_iter iter;
+ for (file = qemu_fwcfg_file_iter_init(&iter);
+ !qemu_fwcfg_file_iter_end(&iter);
+ file = qemu_fwcfg_file_iter_next(&iter)) {
+ if (file->addr) {
+ free((void *)file->addr);
+ file->addr = 0;
+ }
+ }
+ }
free(table_loader);
return addr;
return NULL;
}
-void qemu_fwcfg_free_files(void)
-{
- struct fw_file *file;
- struct list_head *list;
-
- list_for_each(list, &fw_list) {
- file = list_entry(list, struct fw_file, list);
- if (file->addr)
- free((void *)file->addr);
- }
-}
-
struct fw_file *qemu_fwcfg_file_iter_init(struct fw_cfg_file_iter *iter)
{
iter->entry = fw_list.next;
void qemu_fwcfg_read_entry(uint16_t entry, uint32_t length, void *address);
int qemu_fwcfg_read_firmware_list(void);
struct fw_file *qemu_fwcfg_find_file(const char *name);
-void qemu_fwcfg_free_files(void);
/**
* Get system cpu number