public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Alexander Stein <alexanders83@web.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/1] mmc: bcm2835_sdhci: Use calloc to allocate bcm2835_sdhci_host
Date: Fri, 17 Apr 2015 17:33:17 +0200	[thread overview]
Message-ID: <1429284797-8433-1-git-send-email-alexanders83@web.de> (raw)

We need to clear the allocated memory explicitly as the included
struct sdhci_host has function pointers. Those are compared to NULL to
test if this (optional) feature is supported. Leaving them undefined let
u-boot jump to arbitrary memory.

Signed-off-by: Alexander Stein <alexanders83@web.de>
---
 drivers/mmc/bcm2835_sdhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/bcm2835_sdhci.c b/drivers/mmc/bcm2835_sdhci.c
index 92f7d89..127dbe3 100644
--- a/drivers/mmc/bcm2835_sdhci.c
+++ b/drivers/mmc/bcm2835_sdhci.c
@@ -154,9 +154,9 @@ int bcm2835_sdhci_init(u32 regbase, u32 emmc_freq)
 	struct bcm2835_sdhci_host *bcm_host;
 	struct sdhci_host *host;
 
-	bcm_host = malloc(sizeof(*bcm_host));
+	bcm_host = calloc(1, sizeof(*bcm_host));
 	if (!bcm_host) {
-		printf("sdhci_host malloc fail!\n");
+		printf("sdhci_host calloc fail!\n");
 		return 1;
 	}
 
-- 
2.3.5

             reply	other threads:[~2015-04-17 15:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-17 15:33 Alexander Stein [this message]
2015-05-03 14:51 ` [U-Boot] [PATCH 1/1] mmc: bcm2835_sdhci: Use calloc to allocate bcm2835_sdhci_host Alexander Stein
2015-05-05  9:38 ` Pantelis Antoniou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1429284797-8433-1-git-send-email-alexanders83@web.de \
    --to=alexanders83@web.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox