diff --git a/kernel/object.c b/kernel/object.c index b4fea5c..abcd84b 100644 --- a/kernel/object.c +++ b/kernel/object.c @@ -110,7 +110,16 @@ static void object_cleanup(struct object *obj, unsigned long flags) struct queue_entry *entry = queue_pop_front(&queue); struct object *child = NULL; obj->ob_type->ob_ops.destroy_recurse(entry, &child); - if (child) { + if (!child) { + continue; + } + + if (child->ob_refcount > 1) { + child->ob_refcount--; + continue; + } + + if (child->ob_refcount == 0 && child->ob_handles == 0) { __cleanup(child, &queue); } }