From bd6d19e08435e228a1c0bcb02588d283602ce22b Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Fri, 29 Jan 2021 13:39:20 -0600 Subject: [PATCH] netdev: Squash memory leak on module_init failure In the case of module_init failing due to a module that comes after netdev, the netdev module doesn't clean up netdev_list properly. ==6254== 24 bytes in 1 blocks are still reachable in loss record 1 of 1 ==6254== at 0x483777F: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==6254== by 0x4675ED: l_malloc (util.c:61) ==6254== by 0x46909D: l_queue_new (queue.c:63) ==6254== by 0x406AE4: netdev_init (netdev.c:5038) ==6254== by 0x44A7B3: iwd_modules_init (module.c:152) ==6254== by 0x404713: nl80211_appeared (main.c:171) ==6254== by 0x4713DE: process_unicast (genl.c:993) ==6254== by 0x4713DE: received_data (genl.c:1101) ==6254== by 0x46E00B: io_callback (io.c:118) ==6254== by 0x46D20C: l_main_iterate (main.c:477) ==6254== by 0x46D2DB: l_main_run (main.c:524) ==6254== by 0x46D2DB: l_main_run (main.c:506) ==6254== by 0x46D502: l_main_run_with_signal (main.c:656) ==6254== by 0x403EDB: main (main.c:490) --- src/netdev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/netdev.c b/src/netdev.c index 630f61f5..afcafa8e 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -5072,6 +5072,7 @@ static void netdev_exit(void) l_genl_remove_unicast_watch(genl, unicast_watch); watchlist_destroy(&netdev_watches); + l_queue_destroy(netdev_list, netdev_free); l_genl_family_free(nl80211); nl80211 = NULL;