config_plex: don't allocate a rangelock struct.
lockrange: correctly expand rangelock struct, including expanding a null struct. Previously lockrange would attempt to lock a NULL pointer under these circumstances. Reported-by: Ian Freislich <iang@uunet.co.za>
This commit is contained in:
parent
05da76e022
commit
ca55837990
@ -1352,12 +1352,6 @@ config_plex(int update)
|
||||
sprintf(plexsuffix, ".p%d", pindex); /* form the suffix */
|
||||
strcat(plex->name, plexsuffix); /* and add it to the name */
|
||||
}
|
||||
if (plex->organization == plex_raid5) { /* RAID-5 plex, */
|
||||
plex->lock = (struct rangelock *)
|
||||
Malloc(sizeof(struct rangelock) * INITIAL_LOCKS); /* allocate lock table */
|
||||
bzero(plex->lock, sizeof(struct rangelock) * INITIAL_LOCKS); /* zero it */
|
||||
plex->alloclocks = INITIAL_LOCKS; /* and note how many there are */
|
||||
}
|
||||
/* Note the last plex we configured */
|
||||
current_plex = plexno;
|
||||
plex->state = state; /* set whatever state we chose */
|
||||
|
@ -268,10 +268,11 @@ lockrange(daddr_t stripe, struct buf *bp, struct plex *plex)
|
||||
if (foundlocks >= plex->alloclocks) { /* searched the lot, */
|
||||
newlock = plex->alloclocks;
|
||||
EXPAND(plex->lock, struct rangelock, plex->alloclocks, INITIAL_LOCKS);
|
||||
pos = &plex->lock[newlock];
|
||||
while (newlock < plex->alloclocks)
|
||||
plex->lock[newlock++].stripe = 0;
|
||||
}
|
||||
pos = lock; /* put it at the end */
|
||||
} else
|
||||
pos = lock; /* put it at the end */
|
||||
}
|
||||
pos->stripe = stripe;
|
||||
pos->bp = bp;
|
||||
|
Loading…
x
Reference in New Issue
Block a user