From: Kuldeep Singh Date: Fri, 11 Sep 2020 11:06:48 +0000 (+0530) Subject: net: pfe_eth: Fix resoure leak in pfe_spi_flash_init X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=63d534461555c7948eeddf6250f76019b329b15a;p=u-boot.git net: pfe_eth: Fix resoure leak in pfe_spi_flash_init Fix Coverity issue: RESOURCE_LEAK. leaked_storage: Variable addr going out of scope leaks the storage it points to. Fixes: e0152dbed683 ("net: pfe_eth: Use spi_flash_read API to access flash memory") Signed-off-by: Kuldeep Singh Reviewed-by: Priyanka Jain --- diff --git a/drivers/net/pfe_eth/pfe_firmware.c b/drivers/net/pfe_eth/pfe_firmware.c index 55e661c0e1..4ad09dda1c 100644 --- a/drivers/net/pfe_eth/pfe_firmware.c +++ b/drivers/net/pfe_eth/pfe_firmware.c @@ -170,6 +170,9 @@ int pfe_spi_flash_init(void) int ret = 0; void *addr = malloc(CONFIG_SYS_QE_FMAN_FW_LENGTH); + if (!addr) + return -ENOMEM; + #ifdef CONFIG_DM_SPI_FLASH struct udevice *new; @@ -186,6 +189,7 @@ int pfe_spi_flash_init(void) #endif if (!pfe_flash) { printf("SF: probe for pfe failed\n"); + free(addr); return -ENODEV; }