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

[Xen-devel] [PATCH for-4.5 V6 13/14] Fix freeing of uninitialized pointer



The only valid response from the LocateHandle() call is EFI_BUFFER_TOO_SMALL,
so exit if we get anything else.  We pass a 0 size/NULL pointer buffer, so the
only other returns we will get is an error.  Return right away as there is
nothing to do.  Also return if there is an error allocating the buffer, as the
previous code path also allowed for an undefined pointer to be freed.

Signed-off-by: Roy Franz <roy.franz@xxxxxxxxxx>
---
 xen/common/efi/boot.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index d5c9355..54db5c9 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -582,9 +582,15 @@ static void __init setup_efi_pci(void)
     status = efi_bs->LocateHandle(ByProtocol, &pci_guid, NULL, &size, NULL);
     if ( status == EFI_BUFFER_TOO_SMALL )
         status = efi_bs->AllocatePool(EfiLoaderData, size, (void **)&handles);
+    else
+        return;
+
     if ( !EFI_ERROR(status) )
         status = efi_bs->LocateHandle(ByProtocol, &pci_guid, NULL, &size,
                                       handles);
+    else
+        return;
+
     if ( EFI_ERROR(status) )
         size = 0;
 
-- 
2.1.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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