slab: correct lock pointers
This commit is contained in:
parent
aac47e60f3
commit
1fcac9b274
1 changed files with 6 additions and 5 deletions
|
|
@ -81,19 +81,20 @@ void *slab_alloc(slab_t *slab)
|
||||||
if (slab == NULL)
|
if (slab == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
spinlock_acquire(&slab->lock);
|
spinlock_t *lock = &slab->lock;
|
||||||
|
spinlock_acquire(lock);
|
||||||
if (slab->nextfree == NULL) {
|
if (slab->nextfree == NULL) {
|
||||||
if (slab->next == NULL) {
|
if (slab->next == NULL) {
|
||||||
slab->next = slab_create(slab->size, slab->tsize, slab->flags);
|
slab->next = slab_create(slab->size, slab->tsize, slab->flags);
|
||||||
if (slab->next == NULL) {
|
if (slab->next == NULL) {
|
||||||
spinlock_release(&slab->lock);
|
spinlock_release(lock);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
slab->next->prev = slab;
|
slab->next->prev = slab;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *ret = slab_alloc(slab->next);
|
void *ret = slab_alloc(slab->next);
|
||||||
spinlock_release(&slab->lock);
|
spinlock_release(lock);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -102,7 +103,7 @@ void *slab_alloc(slab_t *slab)
|
||||||
uintptr_t *ret = slab->nextfree;
|
uintptr_t *ret = slab->nextfree;
|
||||||
slab->nextfree = (uintptr_t *)*slab->nextfree;
|
slab->nextfree = (uintptr_t *)*slab->nextfree;
|
||||||
|
|
||||||
spinlock_release(&slab->lock);
|
spinlock_release(lock);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue