diff options
-rw-r--r-- | common/cyclic.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/common/cyclic.c b/common/cyclic.c index b695f092f52..75662d9f613 100644 --- a/common/cyclic.c +++ b/common/cyclic.c @@ -28,6 +28,18 @@ struct hlist_head *cyclic_get_list(void) return (struct hlist_head *)&gd->cyclic_list; } +static bool cyclic_is_registered(const struct cyclic_info *cyclic) +{ + const struct cyclic_info *c; + + hlist_for_each_entry(c, cyclic_get_list(), list) { + if (c == cyclic) + return true; + } + + return false; +} + void cyclic_register(struct cyclic_info *cyclic, cyclic_func_t func, uint64_t delay_us, const char *name) { @@ -43,6 +55,9 @@ void cyclic_register(struct cyclic_info *cyclic, cyclic_func_t func, void cyclic_unregister(struct cyclic_info *cyclic) { + if (!cyclic_is_registered(cyclic)) + return; + hlist_del(&cyclic->list); } |