mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-21 14:42:18 +08:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user