Subject: [PATCH] arm64/efi: efi_init error handling fix

From: [email-masked] (Matt Fleming)
Date: Mon, 5 Sep 2016 14:57:23 +0100

On Fri, 02 Sep, at 11:26:18AM, Will Deacon wrote:
> On Fri, Sep 02, 2016 at 06:18:39PM +0800, Xie Yisheng wrote:
> > From: Yisheng Xie <[email-masked]>
> > 
> > There's an early memmap leak in efi_init error path, fix it.
> > 
> > Signed-off-by: Yisheng Xie <[email-masked]>
> > ---
> >  drivers/firmware/efi/arm-init.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> Adding linux-efi, Ard and Matt. Please try to CC the relevant people in
> future.
> 
> Will
> 
> > diff --git a/drivers/firmware/efi/arm-init.c b/drivers/firmware/efi/arm-init.c
> > index c49d50e..5080e40 100644
> > --- a/drivers/firmware/efi/arm-init.c
> > +++ b/drivers/firmware/efi/arm-init.c
> > @@ -243,8 +243,10 @@ void __init efi_init(void)
> >  	     "Unexpected EFI_MEMORY_DESCRIPTOR version %ld",
> >  	      efi.memmap.desc_version);
> >  
> > -	if (uefi_init() < 0)
> > +	if (uefi_init() < 0) {
> > +		early_memunmap(efi.memmap.map, params.mmap_size);
> >  		return;
> > +	}

This should be a call to efi_memmap_unmap() because the EFI_MEMMAP
flag also needs clearing.