summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDaniel Kochmański <dkochmanski@turtle-solutions.eu>2015-05-29 16:55:43 +0200
committerHans de Goede <hdegoede@redhat.com>2015-07-24 16:17:08 +0200
commit1b26bab12e85e8b0d382d6775e40d14445249574 (patch)
treeba3b7462f730fb9bdb0788c64590f2e53d4c4256 /drivers
parent413978d118bb7d7b0a8488d97d802f2899cd81ce (diff)
downloadtalos-obmc-uboot-1b26bab12e85e8b0d382d6775e40d14445249574.tar.gz
talos-obmc-uboot-1b26bab12e85e8b0d382d6775e40d14445249574.zip
mmc: Protect `mmc_initialize` from initialising mmc multiple times
`mmc_initialize` might be called multiple times leading to the mmc-controllers being initialised twice, and initialising the `mmc_devices` list head twice which may lead to memory leaks. Signed-off-by: Daniel Kochmański <dkochmanski@turtle-solutions.eu> CC: Roy Spliet <r.spliet@ultimaker.com> Cc: Ian Campbell <ijc@hellion.org.uk> CC: Pantelis Antoniou <panto@antoniou-consulting.com> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mmc/mmc.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index da47037a30..f12546ac51 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1762,6 +1762,11 @@ static void do_preinit(void)
int mmc_initialize(bd_t *bis)
{
+ static int initialized = 0;
+ if (initialized) /* Avoid initializing mmc multiple times */
+ return 0;
+ initialized = 1;
+
INIT_LIST_HEAD (&mmc_devices);
cur_dev_num = 0;
OpenPOWER on IntegriCloud