[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v6 2/5] efi/boot.c: add file.need_to_free


  • To: Trammell Hudson <hudson@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Tue, 29 Sep 2020 12:45:45 +0200
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 29 Sep 2020 10:46:06 +0000
  • Ironport-sdr: zgMwgsSkk0u8iIM2o3QBfnQWkm3DiTp3c3z2XKZ/WNGiSd7mQZc2ApK1JsDlHiWm+zkvTOmvfy /UTyyQ8R3Iqo0DVslIPEYnKmQP6+01AIBjKIND8MieqKRbyc4HkJXXFwfqq500RVqy7eiFduK0 e4Jod04Y7ZWU+7ZBv7c8+GYKxxG/Np1BNxMLa2GWrgY1MxJcZa3QUHRwr3nUMpIDlR325ULzar wYNbtaBDGMni9GfqwfKvSrZ3EDvGwwoFJG766IWoP2zfdeamQcZDL/jFdta1bv4xrLwnYKqbRq utg=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon, Sep 21, 2020 at 07:51:10AM -0400, Trammell Hudson wrote:
> The config file, kernel, initrd, etc should only be freed if they
> are allocated with the UEFI allocator.
> 
> Signed-off-by: Trammell Hudson <hudson@xxxxxxxx>
> Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> ---
>  xen/common/efi/boot.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
> index 157fe0e8c5..c2ce0c7294 100644
> --- a/xen/common/efi/boot.c
> +++ b/xen/common/efi/boot.c
> @@ -102,6 +102,7 @@ union string {
>  
>  struct file {
>      UINTN size;
> +    bool need_to_free;
>      union {
>          EFI_PHYSICAL_ADDRESS addr;
>          char *str;
> @@ -280,13 +281,13 @@ void __init noreturn blexit(const CHAR16 *str)
>      if ( !efi_bs )
>          efi_arch_halt();
>  
> -    if ( cfg.addr )
> +    if ( cfg.need_to_free )

If you drop the addr check here...

>          efi_bs->FreePages(cfg.addr, PFN_UP(cfg.size));
> -    if ( kernel.addr )
> +    if ( kernel.need_to_free )
>          efi_bs->FreePages(kernel.addr, PFN_UP(kernel.size));
> -    if ( ramdisk.addr )
> +    if ( ramdisk.need_to_free )
>          efi_bs->FreePages(ramdisk.addr, PFN_UP(ramdisk.size));
> -    if ( xsm.addr )
> +    if ( xsm.need_to_free )
>          efi_bs->FreePages(xsm.addr, PFN_UP(xsm.size));
>  
>      efi_arch_blexit();
> @@ -581,6 +582,7 @@ static bool __init read_file(EFI_FILE_HANDLE dir_handle, 
> CHAR16 *name,
>      }
>      else
>      {
> +        file->need_to_free = true;

... I think you need to clear need_to_free if AllocatePages fails?

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.