diff mbox series

[U-Boot,v2] drivers: mmc: Avoid memory leak in case of failure

Message ID 1507184336-6507-1-git-send-email-sunil.m@techveda.org
State Accepted
Delegated to: Jaehoon Chung
Headers show
Series [U-Boot,v2] drivers: mmc: Avoid memory leak in case of failure | expand

Commit Message

Suniel Mahesh Oct. 5, 2017, 6:18 a.m. UTC
From: Suniel Mahesh <sunil.m@techveda.org>

priv pointer should be freed before returning with an error value
from exynos_dwmci_get_config().

Signed-off-by: Suniel Mahesh <sunil.m@techveda.org>
Signed-off-by: Raghu Bharadwaj <raghu@techveda.org>
---
Changes for v2:
- rebased on latest u-boot tree (2017.11.rc1)
- patch was accepted long time ago, but not applied to u-boot-mmc,
  please apply.
---
Note:
Tested on latest u-boot mainline tree, no build issues.
---
 drivers/mmc/exynos_dw_mmc.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Jaehoon Chung Oct. 20, 2017, 11:45 a.m. UTC | #1
On 10/05/2017 03:18 PM, sunil.m@techveda.org wrote:
> From: Suniel Mahesh <sunil.m@techveda.org>
> 
> priv pointer should be freed before returning with an error value
> from exynos_dwmci_get_config().
> 
> Signed-off-by: Suniel Mahesh <sunil.m@techveda.org>
> Signed-off-by: Raghu Bharadwaj <raghu@techveda.org>

Applied to u-boot-mmc.

Best Regards,
Jaehoon Chung

> ---
> Changes for v2:
> - rebased on latest u-boot tree (2017.11.rc1)
> - patch was accepted long time ago, but not applied to u-boot-mmc,
>   please apply.
> ---
> Note:
> Tested on latest u-boot mainline tree, no build issues.
> ---
>  drivers/mmc/exynos_dw_mmc.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c
> index 40f7892..84ef2da 100644
> --- a/drivers/mmc/exynos_dw_mmc.c
> +++ b/drivers/mmc/exynos_dw_mmc.c
> @@ -168,6 +168,7 @@ static int exynos_dwmci_get_config(const void *blob, int node,
>  
>  	if (host->dev_index > 4) {
>  		printf("DWMMC%d: Can't get the dev index\n", host->dev_index);
> +		free(priv);
>  		return -EINVAL;
>  	}
>  
> @@ -178,6 +179,7 @@ static int exynos_dwmci_get_config(const void *blob, int node,
>  	base = fdtdec_get_addr(blob, node, "reg");
>  	if (!base) {
>  		printf("DWMMC%d: Can't get base address\n", host->dev_index);
> +		free(priv);
>  		return -EINVAL;
>  	}
>  	host->ioaddr = (void *)base;
> @@ -187,6 +189,7 @@ static int exynos_dwmci_get_config(const void *blob, int node,
>  	if (err) {
>  		printf("DWMMC%d: Can't get sdr-timings for devider\n",
>  				host->dev_index);
> +		free(priv);
>  		return -EINVAL;
>  	}
>  
>
diff mbox series

Patch

diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c
index 40f7892..84ef2da 100644
--- a/drivers/mmc/exynos_dw_mmc.c
+++ b/drivers/mmc/exynos_dw_mmc.c
@@ -168,6 +168,7 @@  static int exynos_dwmci_get_config(const void *blob, int node,
 
 	if (host->dev_index > 4) {
 		printf("DWMMC%d: Can't get the dev index\n", host->dev_index);
+		free(priv);
 		return -EINVAL;
 	}
 
@@ -178,6 +179,7 @@  static int exynos_dwmci_get_config(const void *blob, int node,
 	base = fdtdec_get_addr(blob, node, "reg");
 	if (!base) {
 		printf("DWMMC%d: Can't get base address\n", host->dev_index);
+		free(priv);
 		return -EINVAL;
 	}
 	host->ioaddr = (void *)base;
@@ -187,6 +189,7 @@  static int exynos_dwmci_get_config(const void *blob, int node,
 	if (err) {
 		printf("DWMMC%d: Can't get sdr-timings for devider\n",
 				host->dev_index);
+		free(priv);
 		return -EINVAL;
 	}