[PATCH 1/2] net: pfe_eth: Fix resoure leak in pfe_spi_flash_init

Priyanka Jain priyanka.jain at nxp.com
Fri Sep 18 15:42:31 CEST 2020


>-----Original Message-----
>From: Kuldeep Singh <kuldeep.singh at nxp.com>
>Sent: Friday, September 11, 2020 4:37 PM
>To: u-boot at lists.denx.de
>Cc: Priyanka Jain <priyanka.jain at nxp.com>; Ashish Kumar
><ashish.kumar at nxp.com>; Kuldeep Singh <kuldeep.singh at nxp.com>
>Subject: [PATCH 1/2] 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 <kuldeep.singh at nxp.com>
>---
> drivers/net/pfe_eth/pfe_firmware.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
>diff --git a/drivers/net/pfe_eth/pfe_firmware.c
>b/drivers/net/pfe_eth/pfe_firmware.c
>index 55e661c..4ad09dd 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;
> 	}
>
>--
>2.7.4
Reviewed-by: Priyanka Jain <priyanka.jain at nxp.com>


More information about the U-Boot mailing list