diff options
author | imp <imp@FreeBSD.org> | 2005-01-20 17:27:37 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2005-01-20 17:27:37 +0000 |
commit | e386a53fa1ab8043891085c22fc172ff6e20d9b3 (patch) | |
tree | 1dec069e3a380246e7681081746b800afb7add98 /sys/dev/fdc | |
parent | 6b74ea5df00af18ebdc9590984689b610c349a46 (diff) | |
download | FreeBSD-src-e386a53fa1ab8043891085c22fc172ff6e20d9b3.zip FreeBSD-src-e386a53fa1ab8043891085c22fc172ff6e20d9b3.tar.gz |
Mask off the upper bits of the resource before using it as an index
into a small array. Also, re-save the dev in attach to avoid
depending on side effects of the probe.
Weird stuff Reported by: jeffr
Diffstat (limited to 'sys/dev/fdc')
-rw-r--r-- | sys/dev/fdc/fdc_isa.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/sys/dev/fdc/fdc_isa.c b/sys/dev/fdc/fdc_isa.c index a6885a9..cb4d317 100644 --- a/sys/dev/fdc/fdc_isa.c +++ b/sys/dev/fdc/fdc_isa.c @@ -88,11 +88,17 @@ fdc_isa_alloc_resources(device_t dev, struct fdc_data *fdc) for (rid = 0; ; rid++) { newrid = rid; - res = bus_alloc_resource(dev, SYS_RES_IOPORT, - &newrid, 0ul, ~0ul, nports, RF_ACTIVE); + res = bus_alloc_resource(dev, SYS_RES_IOPORT, &newrid, + 0ul, ~0ul, nports, RF_ACTIVE); if (res == NULL) break; - i = rman_get_start(res); + /* + * Mask off the upper bits of the register, and sanity + * check resource ranges. + */ + i = rman_get_start(res) & 0x7; + if (i + rman_get_size(res) - 1 > FDC_MAXREG) + return (ENXIO); for (j = 0; j < rman_get_size(res); j++) { fdc->resio[i + j] = res; fdc->ridio[i + j] = newrid; @@ -162,6 +168,7 @@ fdc_isa_attach(device_t dev) int error; fdc = device_get_softc(dev); + fdc->fdc_dev = dev; error = fdc_isa_alloc_resources(dev, fdc); if (error == 0) error = fdc_attach(dev); |