public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Guomin Jiang" <guomin.jiang@intel.com>
To: devel@edk2.groups.io
Cc: Jian J Wang <jian.j.wang@intel.com>,
	Liming Gao <gaoliming@byosoft.com.cn>,
	Zhichao Gao <zhichao.gao@intel.com>, Ray Ni <ray.ni@intel.com>
Subject: [PATCH 1/2] MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error
Date: Tue, 22 Feb 2022 11:40:37 +0800	[thread overview]
Message-ID: <20220222034038.966-2-guomin.jiang@intel.com> (raw)
In-Reply-To: <20220222034038.966-1-guomin.jiang@intel.com>

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.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Guomin Jiang <guomin.jiang@intel.com>
---
 .../Console/GraphicsConsoleDxe/GraphicsConsole.c  | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
index 1bdd1b8a6732..07436cbd15bf 100644
--- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
+++ b/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.
@@ -531,17 +531,6 @@ GraphicsConsoleControllerDriverStart (
         goto Error;
       }
     }
-
-    //
-    // Double confirm SetMode can success
-    //
-    Status = Private->GraphicsOutput->SetMode (Private->GraphicsOutput, ModeNumber);
-    if (EFI_ERROR (Status)) {
-      //
-      // The mode set operation failed
-      //
-      goto Error;
-    }
   } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
     //
     // At first try to set user-defined resolution
-- 
2.35.1.windows.2


  reply	other threads:[~2022-02-22  3:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-22  3:40 [PATCH 0/2] Avoid Emulator Segmentation fault Guomin Jiang
2022-02-22  3:40 ` Guomin Jiang [this message]
2022-02-22  3:40 ` [PATCH 2/2] EmulatorPkg/EmuGopDxe: Set ModeInfo after Open successfully Guomin Jiang
2022-03-01  7:16   ` Ni, Ray
     [not found] ` <16D5FEACC0A8B3B7.28921@groups.io>
2022-02-24  0:55   ` [edk2-devel] " Guomin Jiang
     [not found] ` <16D5FEAC9A733E6B.24964@groups.io>
2022-02-24  0:56   ` [edk2-devel] [PATCH 1/2] MdeModulePkg/GraphicsConsoleDxe: Check status to make sure no error Guomin Jiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220222034038.966-2-guomin.jiang@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox