mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-19 06:44:31 +00:00
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
This commit is contained in:
parent
0502030614
commit
787a196bb7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=140514
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue