]> git.karo-electronics.de Git - karo-tx-uboot.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)
committerLothar Waßmann <LW@KARO-electronics.de>
Wed, 9 Sep 2015 11:49:04 +0000 (13:49 +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 76095f1aa3fce297242e88020328b4b407eb8971..c29f40db5f2d12fa9a504171ecdbd6aa8663d17b 100644 (file)
@@ -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;