
Hi,
On 29-05-15 16:55, Daniel Kochmański wrote:
`mmc_initialize` might be called from various places and initializing list head of `mmc_devices` can 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: Hans De Goede hdegoede@redhat.com CC: Pantelis Antoniou panto@antoniou-consulting.com
Thanks I've merged this one into u-boot-sunxi/next, for inclusion into u-boot v2015.10, I've fixed a few typos in the commit message and clarified the commit message a bit.
Pantelis, since this is an mmc patch may we have your ack for this one please? It is a dep for some sunxi changes so it is probably easiest if I just merge it through the sunxi tree.
Some background, we are adding support for booting from nand, and as such we need to make spl_boot_device() for sunxi smarter. The sunxi BROM does not communicate where it has loaded the SPL from, so we simply retrace it steps trying mmc0 first and looking for a valid bootsignature there.
This means calling mmc_initialize() from spl_boot_device() and if spl_boot_device() then finds a boot signature and returns BOOT_DEVICE_MMC1, then later on spl_mmc_load_image() will call mmc_initialize() a second time, this patch protects against this second call and turns the second call into a nop.
Regards,
Hans
drivers/mmc/mmc.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 79e6fee..2959bde 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1758,6 +1758,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;