summaryrefslogtreecommitdiff
path: root/lib/efi_driver/efi_uclass.c
diff options
context:
space:
mode:
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2022-10-03 10:35:35 +0200
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2022-10-06 22:54:57 +0200
commit43a5891c66c8fe961999415b051c827ce1b543c4 (patch)
tree9d12bda5f09c758bc50aa66f9469a0d6d9c2f9c3 /lib/efi_driver/efi_uclass.c
parent16b27b67c5002c13d84bdf68727954ec765f0731 (diff)
efi_driver: fix error handling
If creating the block device fails, * delete all created objects and references * close the protocol interface on the controller Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Diffstat (limited to 'lib/efi_driver/efi_uclass.c')
-rw-r--r--lib/efi_driver/efi_uclass.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/efi_driver/efi_uclass.c b/lib/efi_driver/efi_uclass.c
index 74dd0032437..5a285aad898 100644
--- a/lib/efi_driver/efi_uclass.c
+++ b/lib/efi_driver/efi_uclass.c
@@ -11,7 +11,7 @@
* The uclass provides the bind, start, and stop entry points for the driver
* binding protocol.
*
- * In bind() and stop() it checks if the controller implements the protocol
+ * In supported() and bind() it checks if the controller implements the protocol
* supported by the EFI driver. In the start() function it calls the bind()
* function of the EFI driver. In the stop() function it destroys the child
* controllers.
@@ -144,18 +144,19 @@ static efi_status_t EFIAPI efi_uc_start(
goto out;
}
ret = check_node_type(controller_handle);
- if (ret != EFI_SUCCESS) {
- r = EFI_CALL(systab.boottime->close_protocol(
- controller_handle, bp->ops->protocol,
- this->driver_binding_handle,
- controller_handle));
- if (r != EFI_SUCCESS)
- EFI_PRINT("Failure to close handle\n");
+ if (ret != EFI_SUCCESS)
+ goto err;
+ ret = bp->ops->bind(controller_handle, interface);
+ if (ret == EFI_SUCCESS)
goto out;
- }
- /* TODO: driver specific stuff */
- bp->ops->bind(controller_handle, interface);
+err:
+ r = EFI_CALL(systab.boottime->close_protocol(
+ controller_handle, bp->ops->protocol,
+ this->driver_binding_handle,
+ controller_handle));
+ if (r != EFI_SUCCESS)
+ EFI_PRINT("Failure to close handle\n");
out:
return EFI_EXIT(ret);