diff --git a/kernel/kent.c b/kernel/kent.c index 3c83a11..7e0945d 100644 --- a/kernel/kent.c +++ b/kernel/kent.c @@ -40,14 +40,13 @@ void kent_get(struct kent *kent) void kent_put(struct kent *kent) { - struct kent *parent = kent->parent; - - if (atom_put(&kent->refcount) == 1) { + do { + struct kent *parent = kent->parent; + if (atom_put(&kent->refcount) != 1) + break; kent->destroy(kent); - - if (parent != NULL) - kent_put(parent); - } + kent = parent; + } while (kent != NULL); } /*