From e55ad34dc82eccd1fcb13a30f5327e02e25213de Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Kochma=C5=84ski?= Date: Fri, 29 May 2015 16:55:43 +0200 Subject: [PATCH] mmc: Protect `mmc_initialize` from initialising mmc multiple times MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit `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 CC: Roy Spliet Cc: Ian Campbell CC: Pantelis Antoniou Acked-by: Hans de Goede Signed-off-by: Hans de Goede --- drivers/mmc/mmc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 76095f1aa3..c29f40db5f 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1766,6 +1766,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; -- 2.39.2