Skip to contentSkip to conversation

mmc/dwmmc: Using calloc instead malloc

PATCH New Chin Liang See 2 participants 2 messages Dec 18, 2013 – Jan 8, 2014 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mmc/dwmmc: Using calloc instead malloc

To enhance the SDMMC DesignWare driver to use calloc instead of malloc. This will avoid the incident that uninitialized members of mmc structure are later used for NULL comparison.

Cc Rajeshwari Shinde <[email protected]>
Cc Jaehoon Chung <[email protected]>
Cc Mischa Jonker <[email protected]>
Cc Alexey Brodkin <[email protected]>
Cc Andy Fleming <[email protected]>
Cc Pantelis Antoniou <[email protected]>

---
Changes for v2
- Adding u-boot-mmc maintainer

---
 drivers/mmc/dw_mmc.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
 mode change 100644 => 100755 drivers/mmc/dw_mmc.c
drivers/mmc/dw_mmc.c +2 -2
old mode 100644
new mode 100755
index 19d9b0b..82abe19
@@ -336,9 +336,9 @@ int add_dwmci(struct dwmci_host *host, u32 max_clk, u32 min_clk)
 	struct mmc *mmc;
 	int err = 0;
 
-	mmc = malloc(sizeof(struct mmc));
+	mmc = calloc(sizeof(struct mmc), 1);
 	if (!mmc) {
-		printf("mmc malloc fail!\n");
+		printf("mmc calloc fail!\n");
 		return -1;
 	}
 
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 1/1 mmc/dwmmc: Using calloc instead malloc

Hi Chin,

Quoted 41 lines · Chin Liang See

To enhance the SDMMC DesignWare driver to use calloc instead of malloc. This will avoid the incident that uninitialized members of mmc structure are later used for NULL comparison.

Cc Rajeshwari Shinde <[email protected]>
Cc Jaehoon Chung <[email protected]>
Cc Mischa Jonker <[email protected]>
Cc Alexey Brodkin <[email protected]>
Cc Andy Fleming <[email protected]>
Cc Pantelis Antoniou <[email protected]>

---
Changes for v2
- Adding u-boot-mmc maintainer
---
drivers/mmc/dw_mmc.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)

mode change 100644 => 100755 drivers/mmc/dw_mmc.c

drivers/mmc/dw_mmc.c +2 -2
old mode 100644
new mode 100755
index 19d9b0b..82abe19
@@ -336,9 +336,9 @@ int add_dwmci(struct dwmci_host *host, u32 max_clk, u32 min_clk)
 	struct mmc *mmc;
 	int err = 0;
 
-	mmc = malloc(sizeof(struct mmc));
+	mmc = calloc(sizeof(struct mmc), 1);
 	if (!mmc) {
-		printf("mmc malloc fail!\n");
+		printf("mmc calloc fail!\n");
 		return -1;
 	}
 
Signature · 1 line
1.7.9.5

Applied, thanks