perf tools: Use list_del_init() more thorougly
To allow for destructors to check if they're operating on a object still in a list, and to avoid going from use after free list entries into still valid, or even also other already removed from list entries. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lkml.kernel.org/n/tip-deh17ub44atyox3j90e6rksu@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
@@ -93,14 +93,14 @@ void thread__delete(struct thread *thread)
|
||||
down_write(&thread->namespaces_lock);
|
||||
list_for_each_entry_safe(namespaces, tmp_namespaces,
|
||||
&thread->namespaces_list, list) {
|
||||
list_del(&namespaces->list);
|
||||
list_del_init(&namespaces->list);
|
||||
namespaces__free(namespaces);
|
||||
}
|
||||
up_write(&thread->namespaces_lock);
|
||||
|
||||
down_write(&thread->comm_lock);
|
||||
list_for_each_entry_safe(comm, tmp_comm, &thread->comm_list, list) {
|
||||
list_del(&comm->list);
|
||||
list_del_init(&comm->list);
|
||||
comm__free(comm);
|
||||
}
|
||||
up_write(&thread->comm_lock);
|
||||
|
||||
Reference in New Issue
Block a user