* [PATCH v2 0/2] MdeModulePkg/UsbBus: Fix system hang when failed to uninstall UsbIo
@ 2017-06-01 11:40 Ruiyu Ni
2017-06-01 11:40 ` [PATCH v2 1/2] " Ruiyu Ni
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Ruiyu Ni @ 2017-06-01 11:40 UTC (permalink / raw)
To: edk2-devel
Please refer to first patch for details.
Patch 2/2 is to correct debug message to ease future debugging.
Ruiyu Ni (2):
MdeModulePkg/UsbBus: Fix system hang when failed to uninstall UsbIo
MdeModulePkg/UsbBus: Correct debug message
MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c | 43 ++++++++++++++++++-----------
MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c | 6 ++--
2 files changed, 30 insertions(+), 19 deletions(-)
--
2.12.2.windows.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/2] MdeModulePkg/UsbBus: Fix system hang when failed to uninstall UsbIo
2017-06-01 11:40 [PATCH v2 0/2] MdeModulePkg/UsbBus: Fix system hang when failed to uninstall UsbIo Ruiyu Ni
@ 2017-06-01 11:40 ` Ruiyu Ni
2017-06-01 11:40 ` [PATCH v2 2/2] MdeModulePkg/UsbBus: Correct debug message Ruiyu Ni
2017-06-01 13:19 ` [PATCH v2 0/2] MdeModulePkg/UsbBus: Fix system hang when failed to uninstall UsbIo Zeng, Star
2 siblings, 0 replies; 4+ messages in thread
From: Ruiyu Ni @ 2017-06-01 11:40 UTC (permalink / raw)
To: edk2-devel; +Cc: Feng Tian, Star Zeng, Hao A Wu
When "reconnect -r" is typed in shell, UsbFreeInterface() is called
to uninstall the UsbIo and DevicePath. But When a UsbIo is opened
by a driver and that driver rejects to close the UsbIo in Stop(),
the uninstall doesn't succeed.
But UsbFreeInterface () frees the DevicePath memory without check
whether the uninstall succeeds.
It leads to the DXE core database contain a DevicePath instance but
that instance's memory is freed.
Assertion happens when someone calls InstallProtocol(DevicePath)
because the InstallProtocol() checks all DevicePath instance to
find whether the same one exits in database.
We haven't seen any USB device driver which rejects to close UsbIo
in Stop(), but it's very likely.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
---
MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c | 43 +++++++++++++++++++-----------
1 file changed, 27 insertions(+), 16 deletions(-)
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
index ea54d37c93..b0e6b835ac 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
@@ -2,7 +2,7 @@
Usb bus enumeration support.
-Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2017, 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
@@ -53,28 +53,33 @@ UsbGetEndpointDesc (
@param UsbIf The USB interface to free.
+ @retval EFI_ACCESS_DENIED The interface is still occupied.
+ @retval EFI_SUCCESS The interface is freed.
**/
-VOID
+EFI_STATUS
UsbFreeInterface (
IN USB_INTERFACE *UsbIf
)
{
- UsbCloseHostProtoByChild (UsbIf->Device->Bus, UsbIf->Handle);
+ EFI_STATUS Status;
- gBS->UninstallMultipleProtocolInterfaces (
- UsbIf->Handle,
- &gEfiDevicePathProtocolGuid,
- UsbIf->DevicePath,
- &gEfiUsbIoProtocolGuid,
- &UsbIf->UsbIo,
- NULL
- );
+ UsbCloseHostProtoByChild (UsbIf->Device->Bus, UsbIf->Handle);
- if (UsbIf->DevicePath != NULL) {
- FreePool (UsbIf->DevicePath);
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ UsbIf->Handle,
+ &gEfiDevicePathProtocolGuid, UsbIf->DevicePath,
+ &gEfiUsbIoProtocolGuid, &UsbIf->UsbIo,
+ NULL
+ );
+ if (!EFI_ERROR (Status)) {
+ if (UsbIf->DevicePath != NULL) {
+ FreePool (UsbIf->DevicePath);
+ }
+ FreePool (UsbIf);
+ } else {
+ UsbOpenHostProtoByChild (UsbIf->Device->Bus, UsbIf->Handle);
}
-
- FreePool (UsbIf);
+ return Status;
}
@@ -525,7 +530,13 @@ UsbRemoveConfig (
Status = UsbDisconnectDriver (UsbIf);
if (!EFI_ERROR (Status)) {
- UsbFreeInterface (UsbIf);
+ Status = UsbFreeInterface (UsbIf);
+ if (EFI_ERROR (Status)) {
+ UsbConnectDriver (UsbIf);
+ }
+ }
+
+ if (!EFI_ERROR (Status)) {
Device->Interfaces[Index] = NULL;
} else {
ReturnStatus = Status;
--
2.12.2.windows.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] MdeModulePkg/UsbBus: Correct debug message
2017-06-01 11:40 [PATCH v2 0/2] MdeModulePkg/UsbBus: Fix system hang when failed to uninstall UsbIo Ruiyu Ni
2017-06-01 11:40 ` [PATCH v2 1/2] " Ruiyu Ni
@ 2017-06-01 11:40 ` Ruiyu Ni
2017-06-01 13:19 ` [PATCH v2 0/2] MdeModulePkg/UsbBus: Fix system hang when failed to uninstall UsbIo Zeng, Star
2 siblings, 0 replies; 4+ messages in thread
From: Ruiyu Ni @ 2017-06-01 11:40 UTC (permalink / raw)
To: edk2-devel; +Cc: Star Zeng
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
---
MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c
index 399b7a3b60..75d9b03af0 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c
@@ -2,7 +2,7 @@
Wrapper function for usb host controller interface.
-Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2017, 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
@@ -1364,10 +1364,10 @@ UsbBusRecursivelyConnectWantedUsbIo (
//
// Recursively connect the wanted Usb Io handle
//
- DEBUG ((EFI_D_INFO, "UsbConnectDriver: TPL before connect is %d\n", (UINT32)UsbGetCurrentTpl ()));
+ DEBUG ((EFI_D_INFO, "UsbBusRecursivelyConnectWantedUsbIo: TPL before connect is %d\n", (UINT32)UsbGetCurrentTpl ()));
Status = gBS->ConnectController (UsbIf->Handle, NULL, NULL, TRUE);
UsbIf->IsManaged = (BOOLEAN)!EFI_ERROR (Status);
- DEBUG ((EFI_D_INFO, "UsbConnectDriver: TPL after connect is %d\n", (UINT32)UsbGetCurrentTpl()));
+ DEBUG ((EFI_D_INFO, "UsbBusRecursivelyConnectWantedUsbIo: TPL after connect is %d\n", (UINT32)UsbGetCurrentTpl()));
}
}
}
--
2.12.2.windows.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 0/2] MdeModulePkg/UsbBus: Fix system hang when failed to uninstall UsbIo
2017-06-01 11:40 [PATCH v2 0/2] MdeModulePkg/UsbBus: Fix system hang when failed to uninstall UsbIo Ruiyu Ni
2017-06-01 11:40 ` [PATCH v2 1/2] " Ruiyu Ni
2017-06-01 11:40 ` [PATCH v2 2/2] MdeModulePkg/UsbBus: Correct debug message Ruiyu Ni
@ 2017-06-01 13:19 ` Zeng, Star
2 siblings, 0 replies; 4+ messages in thread
From: Zeng, Star @ 2017-06-01 13:19 UTC (permalink / raw)
To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Tian, Feng, Wu, Hao A, Zeng, Star
Reviewed-by: Star Zeng <star.zeng@intel.com> to this patch series.
Thanks,
Star
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiyu Ni
Sent: Thursday, June 1, 2017 7:40 PM
To: edk2-devel@lists.01.org
Subject: [edk2] [PATCH v2 0/2] MdeModulePkg/UsbBus: Fix system hang when failed to uninstall UsbIo
Please refer to first patch for details.
Patch 2/2 is to correct debug message to ease future debugging.
Ruiyu Ni (2):
MdeModulePkg/UsbBus: Fix system hang when failed to uninstall UsbIo
MdeModulePkg/UsbBus: Correct debug message
MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c | 43 ++++++++++++++++++----------- MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c | 6 ++--
2 files changed, 30 insertions(+), 19 deletions(-)
--
2.12.2.windows.2
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-06-01 13:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-01 11:40 [PATCH v2 0/2] MdeModulePkg/UsbBus: Fix system hang when failed to uninstall UsbIo Ruiyu Ni
2017-06-01 11:40 ` [PATCH v2 1/2] " Ruiyu Ni
2017-06-01 11:40 ` [PATCH v2 2/2] MdeModulePkg/UsbBus: Correct debug message Ruiyu Ni
2017-06-01 13:19 ` [PATCH v2 0/2] MdeModulePkg/UsbBus: Fix system hang when failed to uninstall UsbIo Zeng, Star
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox