summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/Console
diff options
context:
space:
mode:
authorStar Zeng <star.zeng@intel.com>2015-11-26 08:46:20 +0000
committerlzeng14 <lzeng14@Edk2>2015-11-26 08:46:20 +0000
commitd9b51b21e7ec6c75ba66a6f7b641f79a09c0bdae (patch)
tree7d7957f5a14b104c14f8252e9a5b22ca313e7faa /MdeModulePkg/Universal/Console
parent1b96428d92c01383dc437717db679f57cf70d980 (diff)
downloadedk2-platforms-d9b51b21e7ec6c75ba66a6f7b641f79a09c0bdae.tar.xz
MdeModulePkg: TerminalDxe: avoid checking uninitialized variable
The SerialIo->GetControl() function is not required to set the Control output parameter on error. Make sure we apply the EFI_SERIAL_INPUT_BUFFER_EMPTY optimization in TerminalConInTimerHandler() only if the SerialIo->GetControl() function call set that bit in the Control variable. Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Suggested-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18962 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal/Console')
-rw-r--r--MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
index c216ed900f..3be877b466 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
@@ -2,7 +2,7 @@
Implementation for EFI_SIMPLE_TEXT_INPUT_PROTOCOL protocol.
(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -562,10 +562,11 @@ TerminalConInTimerHandler (
}
//
// Check whether serial buffer is empty.
+ // Skip the key transfer loop only if the SerialIo protocol instance
+ // successfully reports EFI_SERIAL_INPUT_BUFFER_EMPTY.
//
Status = SerialIo->GetControl (SerialIo, &Control);
-
- if ((Control & EFI_SERIAL_INPUT_BUFFER_EMPTY) == 0) {
+ if (EFI_ERROR (Status) || ((Control & EFI_SERIAL_INPUT_BUFFER_EMPTY) == 0)) {
//
// Fetch all the keys in the serial buffer,
// and insert the byte stream into RawFIFO.