return container_of(p, struct audit_chunk, owners[0]);
 }
 
-static void replace_chunk(struct audit_chunk *new, struct audit_chunk *old,
-                         struct node *skip)
+static void replace_chunk(struct audit_chunk *new, struct audit_chunk *old)
 {
        struct audit_tree *owner;
        int i, j;
        list_for_each_entry(owner, &new->trees, same_root)
                owner->root = new;
        for (i = j = 0; j < old->count; i++, j++) {
-               if (&old->owners[j] == skip) {
+               if (!old->owners[j].owner) {
                        i--;
                        continue;
                }
        put_tree(owner);
 }
 
+static int chunk_count_trees(struct audit_chunk *chunk)
+{
+       int i;
+       int ret = 0;
+
+       for (i = 0; i < chunk->count; i++)
+               if (chunk->owners[i].owner)
+                       ret++;
+       return ret;
+}
+
 static void untag_chunk(struct node *p)
 {
        struct audit_chunk *chunk = find_chunk(p);
        struct fsnotify_mark *entry = chunk->mark;
        struct audit_chunk *new = NULL;
-       int size = chunk->count - 1;
+       int size;
 
        remove_chunk_node(chunk, p);
        fsnotify_get_mark(entry);
        spin_unlock(&hash_lock);
 
-       if (size)
-               new = alloc_chunk(size);
-
        mutex_lock(&entry->group->mark_mutex);
        /*
         * mark_mutex protects mark from getting detached and thus also from
                goto out;
        }
 
+       size = chunk_count_trees(chunk);
        if (!size) {
                chunk->dead = 1;
                spin_lock(&hash_lock);
                goto out;
        }
 
+       new = alloc_chunk(size);
        if (!new)
                goto out_mutex;
 
         * This has to go last when updating chunk as once replace_chunk() is
         * called, new RCU readers can see the new chunk.
         */
-       replace_chunk(new, chunk, p);
+       replace_chunk(new, chunk);
        spin_unlock(&hash_lock);
        fsnotify_detach_mark(entry);
        mutex_unlock(&entry->group->mark_mutex);
         * This has to go last when updating chunk as once replace_chunk() is
         * called, new RCU readers can see the new chunk.
         */
-       replace_chunk(chunk, old, NULL);
+       replace_chunk(chunk, old);
        spin_unlock(&hash_lock);
        fsnotify_detach_mark(old_entry);
        mutex_unlock(&audit_tree_group->mark_mutex);