Changeset 6f9a9bc in mainline


Ignore:
Timestamp:
2006-06-06T01:04:01Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
874621f
Parents:
c74804f
Message:

Never ever walk a B+tree as you destroy it. Or vice versa.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • generic/src/mm/as.c

    rc74804f r6f9a9bc  
    137137{
    138138        ipl_t ipl;
    139         link_t *cur;
     139        bool cond;
    140140
    141141        ASSERT(as->refcount == 0);
     
    145145         * it is safe not to lock its mutex.
    146146         */
    147          
    148147        ipl = interrupts_disable();
    149148        spinlock_lock(&inactive_as_with_asid_lock);
    150 
    151149        if (as->asid != ASID_INVALID && as != AS_KERNEL) {
    152                 if (!as->cpu_refcount)
     150                if (as != AS && as->cpu_refcount == 0)
    153151                        list_remove(&as->inactive_as_with_asid_link);
    154152                asid_put(as->asid);
     
    158156        /*
    159157         * Destroy address space areas of the address space.
     158         * The B+tee must be walked carefully because it is
     159         * also being destroyed.
    160160         */     
    161         for (cur = as->as_area_btree.leaf_head.next; cur != &as->as_area_btree.leaf_head; cur = cur->next) {
     161        for (cond = true; cond; ) {
    162162                btree_node_t *node;
    163                 int i;
    164                
    165                 node = list_get_instance(cur, btree_node_t, leaf_link);
    166                 for (i = 0; i < node->keys; i++)
    167                         as_area_destroy(as, node->key[i]);
     163
     164                ASSERT(!list_empty(&as->as_area_btree.leaf_head));
     165                node = list_get_instance(as->as_area_btree.leaf_head.next, btree_node_t, leaf_link);
     166
     167                if ((cond = node->keys)) {
     168                        as_area_destroy(as, node->key[0]);
     169                }
    168170        }
    169171
Note: See TracChangeset for help on using the changeset viewer.