summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2022-10-03 09:47:51 +0200
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2022-10-06 22:54:57 +0200
commit16b27b67c5002c13d84bdf68727954ec765f0731 (patch)
tree46ab97420a9d4e14769d941a2feb5fabbfb2fb76 /lib
parent874490c7ec7a05a429b951720f11a3b966ec0572 (diff)
efi_loader: function to unlink udevice and handle
When deleting a device or a handle we must remove the link between the two to avoid dangling references. Provide function efi_unlink_dev() for this purpose. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/efi_loader/efi_helper.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c
index 8ed564e261..c71e87d118 100644
--- a/lib/efi_loader/efi_helper.c
+++ b/lib/efi_loader/efi_helper.c
@@ -171,3 +171,22 @@ int efi_link_dev(efi_handle_t handle, struct udevice *dev)
handle->dev = dev;
return dev_tag_set_ptr(dev, DM_TAG_EFI, handle);
}
+
+/**
+ * efi_unlink_dev() - unlink udevice and handle
+ *
+ * @handle: EFI handle to unlink
+ *
+ * Return: 0 on success, negative on failure
+ */
+int efi_unlink_dev(efi_handle_t handle)
+{
+ int ret;
+
+ ret = dev_tag_del(handle->dev, DM_TAG_EFI);
+ if (ret)
+ return ret;
+ handle->dev = NULL;
+
+ return 0;
+}