From fbf10601d3fca6076d257916e9bc38c81b3063e1 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Mon, 8 Aug 2011 00:31:41 -0400 Subject: [PATCH] Safe list iteration in kconsumerd: protect against free() Signed-off-by: Mathieu Desnoyers --- liblttkconsumerd/liblttkconsumerd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/liblttkconsumerd/liblttkconsumerd.c b/liblttkconsumerd/liblttkconsumerd.c index f60888a83..a135570fd 100644 --- a/liblttkconsumerd/liblttkconsumerd.c +++ b/liblttkconsumerd/liblttkconsumerd.c @@ -1004,7 +1004,7 @@ end: */ void kconsumerd_cleanup(void) { - struct kconsumerd_fd *iter; + struct kconsumerd_fd *iter, *tmp; /* remove the socket file */ unlink(kconsumerd_command_sock_path); @@ -1014,7 +1014,7 @@ void kconsumerd_cleanup(void) * running (after joining on the threads), no need to protect * list iteration with mutex. */ - cds_list_for_each_entry(iter, &kconsumerd_data.fd_list.head, list) { + cds_list_for_each_entry_safe(iter, tmp, &kconsumerd_data.fd_list.head, list) { kconsumerd_del_fd(iter); } } -- 2.34.1