Kernel: Fix potential UB in AML OpRegion initialization
This commit is contained in:
parent
c96c264801
commit
695262624d
|
@ -243,14 +243,27 @@ namespace Kernel::ACPI::AML
|
||||||
|
|
||||||
BAN::ErrorOr<void> Namespace::initialize_op_regions()
|
BAN::ErrorOr<void> Namespace::initialize_op_regions()
|
||||||
{
|
{
|
||||||
|
struct FullNode
|
||||||
|
{
|
||||||
|
Scope scope;
|
||||||
|
Reference* reference;
|
||||||
|
};
|
||||||
|
|
||||||
|
BAN::Vector<FullNode> op_regions;
|
||||||
|
|
||||||
for (const auto& [obj_path, obj_ref] : m_named_objects)
|
for (const auto& [obj_path, obj_ref] : m_named_objects)
|
||||||
{
|
{
|
||||||
if (obj_ref->node.type != Node::Type::OpRegion)
|
if (obj_ref->node.type != Node::Type::OpRegion)
|
||||||
continue;
|
continue;
|
||||||
// FIXME: if _REG adds stuff to namespace, iterators are invalidated
|
TRY(op_regions.emplace_back(
|
||||||
(void)opregion_call_reg(obj_path, obj_ref->node);
|
TRY(obj_path.copy()),
|
||||||
|
obj_ref
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const auto& [obj_path, obj_ref] : op_regions)
|
||||||
|
(void)opregion_call_reg(obj_path, obj_ref->node);
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue