lib-manager: Free up memory for the library in case of a store error

If lib_manager_store_data() fails to read the rest of the library we need
to free up the allocated memory.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
This commit is contained in:
Peter Ujfalusi 2023-07-31 11:20:42 +03:00 committed by Liam Girdwood
parent 796a3eeb0d
commit 11b9ce23f7
1 changed files with 3 additions and 1 deletions

View File

@ -541,8 +541,10 @@ static int lib_manager_store_library(struct lib_manager_dma_ext *dma_ext,
/* Copy remaining library part into storage buffer */
ret = lib_manager_store_data(dma_ext, (uint8_t __sparse_cache *)library_base_address +
MAN_MAX_SIZE_V1_8, preload_size - MAN_MAX_SIZE_V1_8);
if (ret < 0)
if (ret < 0) {
rfree(library_base_address);
return ret;
}
/* Now update sof context with new library */
lib_manager_update_sof_ctx((__sparse_force void *)library_base_address, lib_id);