mirror of
https://xff.cz/git/u-boot/
synced 2025-09-02 17:22:22 +02:00
efi_loader: avoid crash in OpenProtocol()
When trying to open a protocol exclusively attached drivers have to be removed. This removes entries in the open protocol information linked list over which we are looping. As additionally child controllers may have been removed the only safe thing to do is to restart the loop over the linked list when a driver is removed. By observing the return code of DisconnectController() we can eliminate a loop. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
This commit is contained in:
@@ -2658,21 +2658,29 @@ static efi_status_t efi_protocol_open(
|
|||||||
/* Prepare exclusive opening */
|
/* Prepare exclusive opening */
|
||||||
if (attributes & EFI_OPEN_PROTOCOL_EXCLUSIVE) {
|
if (attributes & EFI_OPEN_PROTOCOL_EXCLUSIVE) {
|
||||||
/* Try to disconnect controllers */
|
/* Try to disconnect controllers */
|
||||||
|
disconnect_next:
|
||||||
|
opened_by_driver = false;
|
||||||
list_for_each_entry(item, &handler->open_infos, link) {
|
list_for_each_entry(item, &handler->open_infos, link) {
|
||||||
|
efi_status_t ret;
|
||||||
|
|
||||||
if (item->info.attributes ==
|
if (item->info.attributes ==
|
||||||
EFI_OPEN_PROTOCOL_BY_DRIVER)
|
EFI_OPEN_PROTOCOL_BY_DRIVER) {
|
||||||
EFI_CALL(efi_disconnect_controller(
|
ret = EFI_CALL(efi_disconnect_controller(
|
||||||
item->info.controller_handle,
|
item->info.controller_handle,
|
||||||
item->info.agent_handle,
|
item->info.agent_handle,
|
||||||
NULL));
|
NULL));
|
||||||
}
|
if (ret == EFI_SUCCESS)
|
||||||
opened_by_driver = false;
|
/*
|
||||||
/* Check if all controllers are disconnected */
|
* Child controllers may have been
|
||||||
list_for_each_entry(item, &handler->open_infos, link) {
|
* removed from the open_infos list. So
|
||||||
if (item->info.attributes & EFI_OPEN_PROTOCOL_BY_DRIVER)
|
* let's restart the loop.
|
||||||
|
*/
|
||||||
|
goto disconnect_next;
|
||||||
|
else
|
||||||
opened_by_driver = true;
|
opened_by_driver = true;
|
||||||
}
|
}
|
||||||
/* Only one controller can be connected */
|
}
|
||||||
|
/* Only one driver can be connected */
|
||||||
if (opened_by_driver)
|
if (opened_by_driver)
|
||||||
return EFI_ACCESS_DENIED;
|
return EFI_ACCESS_DENIED;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user