mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 23:24:38 +00:00
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>
This commit is contained in:
parent
413978d118
commit
1b26bab12e
1 changed files with 5 additions and 0 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue