summaryrefslogtreecommitdiff
path: root/patches/edk2/0002-MdeModulePkg-UefiBootManangerLib-Fix-exception-issue.patch
blob: 281179cd165c64c56e9c9e991daab0455f10042a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From 5954f793dc48f99356c95cd247c13c5da9e48f14 Mon Sep 17 00:00:00 2001
From: Ming Huang <ming.huang@linaro.org>
Date: Tue, 19 Mar 2019 20:59:13 +0800
Subject: [PATCH 2/2] MdeModulePkg/UefiBootManangerLib: Fix exception issue

The system environment: virtual-CDROM(USB interface) via BMC, insert a
iso file to CDROM, like ubuntu-18.04.1-server-arm64.iso, change CDROM
to first boot option.
With release version bios, disconnecting CDROM when boot to
"1 seconds left, Press Esc or F2 to enter Setup"
then system will get a exception.

The root cause is the EFI_BLOCK_IO_PROTOCOL for UsbMass will be uninstalled
in this situation after print some transfer error. The status will be
invalid parameter. This line will get a exception for BlockIo not point
to right address:
AllocatePool (BlockIo->Media->BlockSize)
So, here need to judge the status after ASSERT_EFI_ERROR.

The Bugzilla tracker for this:
https://bugzilla.tianocore.org/show_bug.cgi?id=1631

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang <ming.huang@linaro.org>
---
 MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
index 4ce83ce22d..0535cd7335 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
@@ -1069,6 +1069,9 @@ BmExpandMediaDevicePath (
   //
   Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **) &BlockIo);
   ASSERT_EFI_ERROR (Status);
+  if (EFI_ERROR (Status)) {
+    return NULL;
+  }
   Buffer = AllocatePool (BlockIo->Media->BlockSize);
   if (Buffer != NULL) {
     BlockIo->ReadBlocks (
-- 
2.11.0