From fd1bc0ad5fc3d2d33cd12cdda7241b3f4b6c8616 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Mon, 23 Feb 2026 18:43:11 +0000 Subject: [PATCH] kernel: check object refcount before performing a recursive deletion --- kernel/object.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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); } }