From: "Jan Beulich" Subject: [PATCH] EFI: map allocation size must be set to zero Date: Thu, 11 Jun 2015 12:35:58 +0100 Message-ID: <55798EBE020000780008399E@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartB88C998E.1__=" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Z30m8-00034F-Ob for xen-devel@lists.xenproject.org; Thu, 11 Jun 2015 11:36:00 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Ross Lagerwall List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartB88C998E.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Commit 8a753b3f1c ("efi: fix allocation problems if ExitBootServices() fails") replaced the use of a static (and hence zero-initialized) variable by an automatic (and hence uninitialized) one. Also drop the variable introduced by that commit in favor of re-using another available and suitable one. Signed-off-by: Jan Beulich --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -704,7 +704,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SY EFI_STATUS status; unsigned int i, argc; CHAR16 **argv, *file_name, *cfg_file_name =3D NULL, *options =3D = NULL; - UINTN map_alloc_size, map_key, info_size, gop_mode =3D ~0; + UINTN map_key, info_size, gop_mode =3D ~0; EFI_HANDLE *handles =3D NULL; EFI_SHIM_LOCK_PROTOCOL *shim_lock; EFI_GRAPHICS_OUTPUT_PROTOCOL *gop =3D NULL; @@ -1061,16 +1061,17 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SY efi_arch_video_init(gop, info_size, mode_info); } =20 - efi_bs->GetMemoryMap(&map_alloc_size, NULL, &map_key, + info_size =3D 0; + efi_bs->GetMemoryMap(&info_size, NULL, &map_key, &efi_mdesc_size, &mdesc_ver); - map_alloc_size +=3D 8 * efi_mdesc_size; - efi_memmap =3D efi_arch_allocate_mmap_buffer(map_alloc_size); + info_size +=3D 8 * efi_mdesc_size; + efi_memmap =3D efi_arch_allocate_mmap_buffer(info_size); if ( !efi_memmap ) blexit(L"Unable to allocate memory for EFI memory map"); =20 for ( retry =3D 0; ; retry =3D 1 ) { - efi_memmap_size =3D map_alloc_size; + efi_memmap_size =3D info_size; status =3D efi_bs->GetMemoryMap(&efi_memmap_size, efi_memmap, = &map_key, &efi_mdesc_size, &mdesc_ver); if ( EFI_ERROR(status) ) --=__PartB88C998E.1__= Content-Type: text/plain; name="EFI-init-map-alloc-size.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="EFI-init-map-alloc-size.patch" EFI: map allocation size must be set to zero=0A=0ACommit 8a753b3f1c ("efi: = fix allocation problems if ExitBootServices()=0Afails") replaced the use = of a static (and hence zero-initialized)=0Avariable by an automatic (and = hence uninitialized) one.=0A=0AAlso drop the variable introduced by that = commit in favor of re-using=0Aanother available and suitable one.=0A=0ASign= ed-off-by: Jan Beulich =0A=0A--- a/xen/common/efi/boot.c= =0A+++ b/xen/common/efi/boot.c=0A@@ -704,7 +704,7 @@ efi_start(EFI_HANDLE = ImageHandle, EFI_SY=0A EFI_STATUS status;=0A unsigned int i, = argc;=0A CHAR16 **argv, *file_name, *cfg_file_name =3D NULL, *options = =3D NULL;=0A- UINTN map_alloc_size, map_key, info_size, gop_mode =3D = ~0;=0A+ UINTN map_key, info_size, gop_mode =3D ~0;=0A EFI_HANDLE = *handles =3D NULL;=0A EFI_SHIM_LOCK_PROTOCOL *shim_lock;=0A = EFI_GRAPHICS_OUTPUT_PROTOCOL *gop =3D NULL;=0A@@ -1061,16 +1061,17 @@ = efi_start(EFI_HANDLE ImageHandle, EFI_SY=0A efi_arch_video_init= (gop, info_size, mode_info);=0A }=0A =0A- efi_bs->GetMemoryMap(&map_= alloc_size, NULL, &map_key,=0A+ info_size =3D 0;=0A+ efi_bs->GetMemor= yMap(&info_size, NULL, &map_key,=0A &efi_mdesc_siz= e, &mdesc_ver);=0A- map_alloc_size +=3D 8 * efi_mdesc_size;=0A- = efi_memmap =3D efi_arch_allocate_mmap_buffer(map_alloc_size);=0A+ = info_size +=3D 8 * efi_mdesc_size;=0A+ efi_memmap =3D efi_arch_allocate_= mmap_buffer(info_size);=0A if ( !efi_memmap )=0A blexit(L"Unabl= e to allocate memory for EFI memory map");=0A =0A for ( retry =3D 0; ; = retry =3D 1 )=0A {=0A- efi_memmap_size =3D map_alloc_size;=0A+ = efi_memmap_size =3D info_size;=0A status =3D efi_bs->GetMemor= yMap(&efi_memmap_size, efi_memmap, &map_key,=0A = &efi_mdesc_size, &mdesc_ver);=0A if ( EFI_ERROR(status) = )=0A --=__PartB88C998E.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__PartB88C998E.1__=--