Skip to contentSkip to conversation

drivers: mmc: Avoid memory leak in case of failure

PATCH New sunil.m at techveda.org 2 participants 7 messages Jun 19, 2017 – Oct 20, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: mmc: Avoid memory leak in case of failure

From: Suniel Mahesh <[email protected]>

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

---
 drivers/mmc/exynos_dw_mmc.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/mmc/exynos_dw_mmc.c +3 -0
index 40f7892..84ef2da 100644
@@ -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;
 	}
 
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 drivers: mmc: Avoid memory leak in case of failure

Quoted 7 lines · sunil.m at techveda.org

From: Suniel Mahesh <[email protected]>

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

Applied to u-boot-mmc.

Best Regards,
Jaehoon Chung

Quoted 33 lines
---
 drivers/mmc/exynos_dw_mmc.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/mmc/exynos_dw_mmc.c +3 -0
index 40f7892..84ef2da 100644
@@ -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;
 	}
 
#2 lore raw

PATCH 1/1 drivers: mmc: Avoid memory leak in case of failure

Quoted 10 lines · Jaehoon Chung
Quoted 7 lines · sunil.m at techveda.org

From: Suniel Mahesh <[email protected]>

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

Applied to u-boot-mmc.

Hi, It says the patch has been applied to u-boot-mmc git tree, but I couldn't find it there applied.
http://git.denx.de/?p=u-boot/u-boot-mmc.git;a=summary

are there any issues with the patch or am I looking at the wrong place ?

Thanks
suniel

Quoted 37 lines

Best Regards,
Jaehoon Chung

Quoted 33 lines
---
 drivers/mmc/exynos_dw_mmc.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/mmc/exynos_dw_mmc.c +3 -0
index 40f7892..84ef2da 100644
@@ -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;
 	}
 
#3 lore raw

PATCH 1/1 drivers: mmc: Avoid memory leak in case of failure

Quoted 10 lines · Suniel Mahesh
Quoted 9 lines · Jaehoon Chung
Quoted 7 lines · sunil.m at techveda.org

From: Suniel Mahesh <[email protected]>

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

Quoted 7 lines
Quoted 1 line

Applied to u-boot-mmc.

Hi, It says the patch has been applied to u-boot-mmc git tree, but I couldn't find it there applied.
http://git.denx.de/?p=u-boot/u-boot-mmc.git;a=summary

are there any issues with the patch or am I looking at the wrong place ?

Right place..Sorry..i missed it..when i rebased..will re-apply. Thanks for pointing out.

Best Regards,
Jaehoon Chung

Quoted 45 lines

Thanks
suniel

Quoted 37 lines

Best Regards,
Jaehoon Chung

Quoted 33 lines
---
 drivers/mmc/exynos_dw_mmc.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/mmc/exynos_dw_mmc.c +3 -0
index 40f7892..84ef2da 100644
@@ -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;
 	}
 
#4 lore raw

PATCH 1/1 drivers: mmc: Avoid memory leak in case of failure

Quoted 13 lines · Jaehoon Chung
Quoted 12 lines · Suniel Mahesh
Quoted 10 lines · Jaehoon Chung
Quoted 7 lines · sunil.m at techveda.org

From: Suniel Mahesh <[email protected]>

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

Applied to u-boot-mmc.

Quoted 8 lines
Quoted 5 lines

Hi, It says the patch has been applied to u-boot-mmc git tree, but I couldn't find it there applied.
http://git.denx.de/?p=u-boot/u-boot-mmc.git;a=summary

are there any issues with the patch or am I looking at the wrong place ?

Right place..Sorry..i missed it..when i rebased..will re-apply. Thanks for pointing out.

Hi,
Just a reminder, please re-apply.

I am rebasing the patch w.r.t latest u-boot source tree and will shortly send it.

Thanks
suniel

Quoted 50 lines

Best Regards,
Jaehoon Chung

Quoted 45 lines

Thanks
suniel

Quoted 37 lines

Best Regards,
Jaehoon Chung

Quoted 33 lines
---
 drivers/mmc/exynos_dw_mmc.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/mmc/exynos_dw_mmc.c +3 -0
index 40f7892..84ef2da 100644
@@ -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;
 	}
 
#5 lore raw

PATCH v2 1/1 drivers: mmc: Avoid memory leak in case of failure

In reply to Jaehoon Chung

From: Suniel Mahesh <[email protected]>

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

---
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(+)
drivers/mmc/exynos_dw_mmc.c +3 -0
index 40f7892..84ef2da 100644
@@ -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;
 	}
 
Signature · 1 line
1.9.1
#6 lore raw

PATCH v2 1/1 drivers: mmc: Avoid memory leak in case of failure

Quoted 7 lines · sunil.m at techveda.org

From: Suniel Mahesh <[email protected]>

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

Applied to u-boot-mmc.

Best Regards,
Jaehoon Chung

Quoted 41 lines

---
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(+)
drivers/mmc/exynos_dw_mmc.c +3 -0
index 40f7892..84ef2da 100644
@@ -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;
 	}