acpi: Don't assume a resource is reserved in acpi_delete_resource

This fixes a panic if a driver uses bus_set_resource to add a resource
that fails to reserve and then deletes the resource via
bus_delete_resource.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D43891
This commit is contained in:
John Baldwin 2024-02-14 14:07:32 -08:00
parent 51f8ac224f
commit e05436d577

View file

@ -1629,7 +1629,8 @@ acpi_delete_resource(device_t bus, device_t child, int type, int rid)
" (type=%d, rid=%d)\n", type, rid);
return;
}
resource_list_unreserve(rl, bus, child, type, rid);
if (resource_list_reserved(rl, type, rid))
resource_list_unreserve(rl, bus, child, type, rid);
resource_list_delete(rl, type, rid);
}