diff options
author | mav <mav@FreeBSD.org> | 2009-02-10 23:22:29 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2009-02-10 23:22:29 +0000 |
commit | 26e8dd306f6f8d85825a376452545304c41039e9 (patch) | |
tree | a030e11ce2b2b16b92f393857182184630445259 | |
parent | 556b4fb0466afa487879fd40f612de26a5276bd1 (diff) | |
download | FreeBSD-src-26e8dd306f6f8d85825a376452545304c41039e9.zip FreeBSD-src-26e8dd306f6f8d85825a376452545304c41039e9.tar.gz |
Check for device_set_devclass() errors and skip driver probe/attach if any.
Attach call without devclass set crashes the system.
On resume AHCI driver sometimes tries to create duplicate adX device.
It is surely his own problem, but IMHO it is not a reason to crash here.
Other reasons are also possible.
-rw-r--r-- | sys/kern/subr_bus.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index a74bb51..d226549 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -1756,8 +1756,13 @@ device_probe_child(device_t dev, device_t child) dl = next_matching_driver(dc, child, dl)) { PDEBUG(("Trying %s", DRIVERNAME(dl->driver))); device_set_driver(child, dl->driver); - if (!hasclass) - device_set_devclass(child, dl->driver->name); + if (!hasclass) { + if (device_set_devclass(child, dl->driver->name)) { + PDEBUG(("Unable to set device class")); + device_set_driver(child, NULL); + continue; + } + } /* Fetch any flags for the device before probing. */ resource_int_value(dl->driver->name, child->unit, @@ -1843,8 +1848,11 @@ device_probe_child(device_t dev, device_t child) return (result); /* Set the winning driver, devclass, and flags. */ - if (!child->devclass) - device_set_devclass(child, best->driver->name); + if (!child->devclass) { + result = device_set_devclass(child, best->driver->name); + if (result != 0) + return (result); + } device_set_driver(child, best->driver); resource_int_value(best->driver->name, child->unit, "flags", &child->devflags); |