Browse Source

MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2668

SetMode will fail in some case. for example, without XServer.
Should handle these case when SetMode fail.

If we don't handle it, it will Segmentation fault.

Reviewed-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Guomin Jiang <guomin.jiang@intel.com>
Guomin Jiang 2 years ago
parent
commit
906242343f

+ 2 - 2
MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c

@@ -1,7 +1,7 @@
 /** @file
   This is the main routine for initializing the Graphics Console support routines.
 
-Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -518,7 +518,7 @@ GraphicsConsoleControllerDriverStart (
       }
     }
 
-    if (ModeNumber != Private->GraphicsOutput->Mode->Mode) {
+    if (EFI_ERROR (Status) || (ModeNumber != Private->GraphicsOutput->Mode->Mode)) {
       //
       // Current graphics mode is not set or is not set to the mode which we have found,
       // set the new graphic mode.