From: Mathieu Desnoyers Date: Mon, 8 Aug 2011 04:31:41 +0000 (-0400) Subject: Safe list iteration in kconsumerd: protect against free() X-Git-Tag: v2.0-pre8~4 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=fbf10601d3fca6076d257916e9bc38c81b3063e1;p=lttng-tools.git Safe list iteration in kconsumerd: protect against free() Signed-off-by: Mathieu Desnoyers --- 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); } }