return 1;
}
+static void efi_disk_free_diskobj(struct efi_disk_obj *diskobj)
+{
+ struct efi_device_path *dp = diskobj->dp;
+ struct efi_simple_file_system_protocol *volume = diskobj->volume;
+
+ /*
+ * ignore error of efi_delete_handle() since this function
+ * is expected to be called in error path.
+ */
+ efi_delete_handle(&diskobj->header);
+ efi_free_pool(dp);
+ free(volume);
+}
+
/**
* efi_disk_add_dev() - create a handle for a partition or disk
*
}
return EFI_SUCCESS;
error:
- efi_delete_handle(&diskobj->header);
- free(diskobj->volume);
- free(diskobj);
+ efi_disk_free_diskobj(diskobj);
return ret;
}
return ret;
}
if (efi_link_dev(&disk->header, dev)) {
- efi_free_pool(disk->dp);
- efi_delete_handle(&disk->header);
+ efi_disk_free_diskobj(disk);
return -EINVAL;
}
return -1;
}
if (efi_link_dev(&disk->header, dev)) {
- efi_free_pool(disk->dp);
- efi_delete_handle(&disk->header);
+ efi_disk_free_diskobj(disk);
+
+ /* TODO: closing the parent EFI_BLOCK_IO_PROTOCOL is missing. */
return -1;
}