Clean up resources properly if acpi_perf fails to attach. First, change
acpi_bus_alloc_gas() to delete the resource it set if alloc fails. Then, change acpi_perf to delete the resource after releasing it if alloc fails. This should make probe and attach both fully restartable if either fails.
This commit is contained in:
parent
bc4c871230
commit
ca2c69c8ef
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=144197
@ -1119,19 +1119,15 @@ acpi_bus_alloc_gas(device_t dev, int *type, int *rid, ACPI_GENERIC_ADDRESS *gas,
|
||||
if (!ACPI_VALID_ADDRESS(gas->Address) || gas->RegisterBitWidth == 0)
|
||||
return (EINVAL);
|
||||
|
||||
/*
|
||||
* Delete any previous resource before setting the new one. Note this
|
||||
* will panic if the resource is still allocated but that will reveal
|
||||
* any driver bugs.
|
||||
*/
|
||||
bus_delete_resource(dev, res_type, *rid);
|
||||
bus_set_resource(dev, res_type, *rid, gas->Address,
|
||||
gas->RegisterBitWidth / 8);
|
||||
*res = bus_alloc_resource_any(dev, res_type, rid, RF_ACTIVE);
|
||||
if (*res != NULL) {
|
||||
*type = res_type;
|
||||
error = 0;
|
||||
}
|
||||
} else
|
||||
bus_delete_resource(dev, res_type, *rid);
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
@ -196,6 +196,7 @@ acpi_perf_probe(device_t dev)
|
||||
switch (error) {
|
||||
case 0:
|
||||
bus_release_resource(dev, type, rid, res);
|
||||
bus_delete_resource(dev, type, rid);
|
||||
device_set_desc(dev, "ACPI CPU Frequency Control");
|
||||
break;
|
||||
case EOPNOTSUPP:
|
||||
@ -354,8 +355,23 @@ acpi_perf_evaluate(device_t dev)
|
||||
|
||||
out:
|
||||
if (error) {
|
||||
if (sc->px_states)
|
||||
if (sc->px_states) {
|
||||
free(sc->px_states, M_ACPIPERF);
|
||||
sc->px_states = NULL;
|
||||
}
|
||||
if (sc->perf_ctrl) {
|
||||
bus_release_resource(sc->dev, sc->perf_ctrl_type, 0,
|
||||
sc->perf_ctrl);
|
||||
bus_delete_resource(sc->dev, sc->perf_ctrl_type, 0);
|
||||
sc->perf_ctrl = NULL;
|
||||
}
|
||||
if (sc->perf_status) {
|
||||
bus_release_resource(sc->dev, sc->perf_sts_type, 1,
|
||||
sc->perf_status);
|
||||
bus_delete_resource(sc->dev, sc->perf_sts_type, 1);
|
||||
sc->perf_status = NULL;
|
||||
}
|
||||
sc->px_rid = 0;
|
||||
sc->px_count = 0;
|
||||
}
|
||||
if (buf.Pointer)
|
||||
|
Loading…
Reference in New Issue
Block a user