Some error paths in flash_setup_buffer() fail to free the flash_info struct
or close the open ffs before they return. Change them to goto the cleanup
code at the end. Separate the cleanup code into separate labels depending
on whether we need to call ffs_close(), arch_flash_close() and
talloc_free().
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
rc = arch_flash_init(&info->bl, NULL, true);
if (rc) {
pb_log("Failed to init mtd device\n");
rc = arch_flash_init(&info->bl, NULL, true);
if (rc) {
pb_log("Failed to init mtd device\n");
}
rc = blocklevel_get_info(info->bl, &info->path, &info->size,
&info->erase_granule);
if (rc) {
pb_log("Failed to retrieve blocklevel info\n");
}
rc = blocklevel_get_info(info->bl, &info->path, &info->size,
&info->erase_granule);
if (rc) {
pb_log("Failed to retrieve blocklevel info\n");
}
rc = ffs_init(0, info->size, info->bl, &info->ffs, 1);
if (rc) {
pb_log("%s: Failed to init ffs\n", __func__);
}
rc = ffs_init(0, info->size, info->bl, &info->ffs, 1);
if (rc) {
pb_log("%s: Failed to init ffs\n", __func__);
}
rc = partition_info(info, partition);
if (rc) {
pb_log("Failed to retrieve partition info\n");
}
rc = partition_info(info, partition);
if (rc) {
pb_log("Failed to retrieve partition info\n");
}
/* Check if there is a second flash side. If there is not, or
}
/* Check if there is a second flash side. If there is not, or
+out_ffs:
+ ffs_close(info->ffs);
+out_flash:
arch_flash_close(info->bl, NULL);
arch_flash_close(info->bl, NULL);
talloc_free(info);
return NULL;
}
talloc_free(info);
return NULL;
}