From 5d0e003c8ce2616c763f8edd4ac18f560d418e76 Mon Sep 17 00:00:00 2001 From: fanwang2 Date: Fri, 8 Dec 2017 09:08:24 +0800 Subject: [PATCH] MdeModulePkg/NetLib: Fix an error when AIP doesn't support network media state detection AIP may not support detecting network media state, in this case, should call NetLibDetectMedia to get media state. This patch is to fix this issue. Cc: Fu Siyuan Cc: Ye Ting Cc: Jiaxin Wu Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wang Fan Reviewed-by: Fu Siyuan Reviewed-by: Jiaxin Wu --- MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c index 1bfa33d58d..d75cca29d6 100644 --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c @@ -2605,6 +2605,24 @@ NetLibDetectMediaWaitTimeout ( if (MediaInfo != NULL) { FreePool (MediaInfo); } + + if (Status == EFI_UNSUPPORTED) { + + // + // If gEfiAdapterInfoMediaStateGuid is not supported, call NetLibDetectMedia to get media state! + // + MediaPresent = TRUE; + Status = NetLibDetectMedia (ServiceHandle, &MediaPresent); + if (!EFI_ERROR (Status)) { + if (MediaPresent == TRUE) { + *MediaState = EFI_SUCCESS; + } else { + *MediaState = EFI_NO_MEDIA; + } + } + return Status; + } + return Status; } -- 2.39.2