From 5d2539fc4a363f518efa8ba4ee045d7b80ce632a Mon Sep 17 00:00:00 2001 From: fef Date: Mon, 10 Oct 2022 14:32:29 +0200 Subject: [PATCH] kent: avoid recursion --- kernel/kent.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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); } /*