[U-Boot] [PATCH v2] 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.
Signed-off-by: Chin Liang See clsee@altera.com Cc: Rajeshwari Shinde rajeshwari.s@samsung.com Cc: Jaehoon Chung jh80.chung@samsung.com Cc: Mischa Jonker mjonker@synopsys.com Cc: Alexey Brodkin abrodkin@synopsys.com Cc: Andy Fleming afleming@freescale.com Cc: Pantelis Antoniou panto@antoniou-consulting.com --- 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
diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c old mode 100644 new mode 100755 index 19d9b0b..82abe19 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -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; }

Hi Chin,
On Dec 18, 2013, at 7:16 PM, Chin Liang See wrote:
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.
Signed-off-by: Chin Liang See clsee@altera.com Cc: Rajeshwari Shinde rajeshwari.s@samsung.com Cc: Jaehoon Chung jh80.chung@samsung.com Cc: Mischa Jonker mjonker@synopsys.com Cc: Alexey Brodkin abrodkin@synopsys.com Cc: Andy Fleming afleming@freescale.com Cc: Pantelis Antoniou panto@antoniou-consulting.com
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
diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c old mode 100644 new mode 100755 index 19d9b0b..82abe19 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -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");
return -1; }printf("mmc calloc fail!\n");
-- 1.7.9.5
Applied, thanks
Acked-by: Pantelis Antoniou panto@antoniou-consulting.com
participants (2)
-
Chin Liang See
-
Pantelis Antoniou