From b7a5261508cdd61566e47598079e8040a5a09cab Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Thu, 2 Feb 2023 17:44:24 +0100 Subject: [PATCH] sys/net/grnc/netreg: avoid creating an infinite loop --- sys/net/gnrc/netreg/gnrc_netreg.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sys/net/gnrc/netreg/gnrc_netreg.c b/sys/net/gnrc/netreg/gnrc_netreg.c index bf26713ac1..e56f0dda13 100644 --- a/sys/net/gnrc/netreg/gnrc_netreg.c +++ b/sys/net/gnrc/netreg/gnrc_netreg.c @@ -152,6 +152,13 @@ int gnrc_netreg_register(gnrc_nettype_t type, gnrc_netreg_entry_t *entry) } _gnrc_netreg_acquire_exclusive(); + + /* don't add the same entry twice */ + gnrc_netreg_entry_t *e; + LL_FOREACH(netreg[type], e) { + assert(entry != e); + } + LL_PREPEND(netreg[type], entry); _gnrc_netreg_release_exclusive();