Skip to content

Commit

Permalink
flash: npcx: fix memory leak in npcx_flash_bank_command
Browse files Browse the repository at this point in the history
Recent commit 62f76b2 ("flash/nor: add support for Nuvoton
NPCX4/K3 series flash") introduces a memory leak for a missing
free() on early return for an error.

Add the free() on the return path on error.

Change-Id: Ica8568a986802e23df2ab7bed4e8cc4bbb6305a5
Signed-off-by: Antonio Borneo <[email protected]>
Fixes: 62f76b2 ("flash/nor: add support for Nuvoton NPCX4/K3 series flash")
Reviewed-on: https://review.openocd.org/c/openocd/+/7894
Tested-by: jenkins
Reviewed-by: Tomas Vanek <[email protected]>
  • Loading branch information
borneoa committed Sep 17, 2023
1 parent 300fe1d commit 8bbbff1
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/flash/nor/npcx.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ FLASH_BANK_COMMAND_HANDLER(npcx_flash_bank_command)
npcx_bank->fiu_ver = NPCX_FIU_NPCK;
} else {
LOG_ERROR("%s is not a valid fiu", fiu);
free(npcx_bank);
return ERROR_TARGET_INVALID;
}
}
Expand Down

0 comments on commit 8bbbff1

Please sign in to comment.