]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
mmc: Protect `mmc_initialize` from initialising mmc multiple times
authorDaniel Kochmański <dkochmanski@turtle-solutions.eu>
Fri, 29 May 2015 14:55:43 +0000 (16:55 +0200)
committerHans de Goede <hdegoede@redhat.com>
Fri, 24 Jul 2015 14:17:08 +0000 (16:17 +0200)
`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>
drivers/mmc/mmc.c

index da47037a3066260a5596d35c1cf033f7102c2afe..f12546ac51925a9e249ffb1a8fbdf8cd6f91ea04 100644 (file)
@@ -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;