summaryrefslogtreecommitdiffstats
path: root/lib/route
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-03-14 08:03:19 (GMT)
committerThomas Haller <thaller@redhat.com>2022-03-14 08:04:00 (GMT)
commit1ac5403f414deea7074ed2a5a4dfc27c88330fd2 (patch)
tree50513b9cd771eebabb5ac50ff2d23711445d7df5 /lib/route
parent92035e25e6207c8b2902f1bd931503c33d82ddaf (diff)
downloadlibnl-1ac5403f414deea7074ed2a5a4dfc27c88330fd2.zip
libnl-1ac5403f414deea7074ed2a5a4dfc27c88330fd2.tar.gz
libnl-1ac5403f414deea7074ed2a5a4dfc27c88330fd2.tar.bz2
route/mdb: use nl_list_for_each_entry_safe() for destroying list in mdb_free_data()
I think this was wrong before. We cannot use mdb_free_data() and free the current element. Use nl_list_for_each_entry_safe() and properly unlink the element.
Diffstat (limited to 'lib/route')
-rw-r--r--lib/route/mdb.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/route/mdb.c b/lib/route/mdb.c
index 5872103..6f43cd1 100644
--- a/lib/route/mdb.c
+++ b/lib/route/mdb.c
@@ -26,19 +26,17 @@ static void mdb_constructor(struct nl_object *obj)
nl_init_list_head(&_mdb->mdb_entry_list);
}
-static void mdb_entry_free_data(struct rtnl_mdb_entry *entry)
-{
- nl_addr_put(entry->addr);
- free(entry);
-}
-
static void mdb_free_data(struct nl_object *obj)
{
struct rtnl_mdb *mdb = (struct rtnl_mdb *) obj;
struct rtnl_mdb_entry *mdb_entry;
+ struct rtnl_mdb_entry *mdb_entry_safe;
- nl_list_for_each_entry(mdb_entry, &mdb->mdb_entry_list, mdb_list)
- mdb_entry_free_data(mdb_entry);
+ nl_list_for_each_entry_safe(mdb_entry, mdb_entry_safe, &mdb->mdb_entry_list, mdb_list) {
+ nl_list_del(&mdb_entry->mdb_list);
+ nl_addr_put(mdb_entry->addr);
+ free(mdb_entry);
+ }
}
static uint64_t mdb_entry_compare(struct nl_object *_a, struct nl_object *_b,