In detach(), check for failure of bus_generic_detach(), only release

resources if they got allocated (because detach() gets called from attach()
to handle various failures), and delete the pwmbus child if it got created.
This commit is contained in:
ian 2019-06-15 16:36:29 +00:00
parent 9a81ededb0
commit f529a45660

View File

@ -192,12 +192,20 @@ static int
aw_pwm_detach(device_t dev)
{
struct aw_pwm_softc *sc;
int error;
sc = device_get_softc(dev);
bus_generic_detach(sc->dev);
if (((error = bus_generic_detach(sc->dev)) != 0) {
device_printf(sc->dev, "cannot detach child devices\n");
return (error);
}
bus_release_resources(dev, aw_pwm_spec, &sc->res);
if (sc->busdev != NULL)
device_delete_child(dev, sc->busdev);
if (sc->res != NULL)
bus_release_resources(dev, aw_pwm_spec, &sc->res);
return (0);
}