Fixed allocation of unit numbers. Allocate the amount of space actually
required (rounded up a little) instead of twice the previous amount (or a fixed amount for the first allocation). The bug caused memory corruption when a new unit number for a devclass was more than about twice the previous maximum one (or more than 3 for the first one), so it corrupted memory (which happened to be the atkbdc port resource list) in the reporter's configuration with sio unit numbers { 0, 25, 1, 2, ... }. Reviewed by: dfr Reported by: Leonid Lukiyanets <stalwar78@hotmail.com>
This commit is contained in:
parent
423e956387
commit
d6f5631720
@ -376,8 +376,7 @@ devclass_alloc_unit(devclass_t dc, int *unitp)
|
||||
device_t *newlist;
|
||||
int newsize;
|
||||
|
||||
newsize = (dc->maxunit ? 2 * dc->maxunit
|
||||
: MINALLOCSIZE / sizeof(device_t));
|
||||
newsize = roundup((unit + 1), MINALLOCSIZE / sizeof(device_t));
|
||||
newlist = malloc(sizeof(device_t) * newsize, M_BUS, M_NOWAIT);
|
||||
if (!newlist)
|
||||
return ENOMEM;
|
||||
|
Loading…
x
Reference in New Issue
Block a user