bsps/flash: Fix resource leak in flash_sim_flashdev_init (CID 1679602)

The allocation of ftable was not freed in error handling paths.
This patch ensures ftable is freed if subsequent allocations fail.

CID 1679602
This commit is contained in:
M Mithilesh
2026-01-13 23:01:31 +05:30
parent 5384a26b48
commit 6e4f134238
@@ -414,6 +414,7 @@ rtems_flashdev *flash_sim_flashdev_init(
ntable->area = flashdev_malloc( &ntable->attr, total_pages * ntable->attr.page_size_bytes );
if ( ntable->area == NULL ) {
free( ftable );
free_nand_priv( ntable );
return NULL;
}
@@ -422,6 +423,7 @@ rtems_flashdev *flash_sim_flashdev_init(
if ( ntable->attr.type == RTEMS_FLASHDEV_NAND ) {
ntable->oob = flashdev_malloc( &ntable->attr, total_pages * ntable->attr.page_oob_bytes );
if ( ntable->oob == NULL ) {
free( ftable );
free_nand_priv( ntable );
return NULL;
}