From: Daniel Kochmański Date: Fri, 29 May 2015 14:55:43 +0000 (+0200) Subject: mmc: Protect `mmc_initialize` from initialising mmc multiple times X-Git-Tag: v2015.10-rc1~69^2~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1b26bab12e85e8b0d382d6775e40d14445249574;p=platform%2Fkernel%2Fu-boot.git 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 CC: Roy Spliet Cc: Ian Campbell CC: Pantelis Antoniou Acked-by: Hans de Goede Signed-off-by: Hans de Goede --- diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index da47037..f12546a 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;