aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2019-02-23 10:07:21 (GMT)
committerJouni Malinen <j@w1.fi>2019-02-25 17:42:34 (GMT)
commit3b6b3ae5813329fa69d86a553ff263bc17e8b41b (patch)
tree82af455c08f84fb6deec96cea16a32f6c6bab33d
parent1415d4b82d5eab4c8edf2c2b32200137ae0178c3 (diff)
downloadhostap-3b6b3ae5813329fa69d86a553ff263bc17e8b41b.zip
hostap-3b6b3ae5813329fa69d86a553ff263bc17e8b41b.tar.gz
hostap-3b6b3ae5813329fa69d86a553ff263bc17e8b41b.tar.bz2
Modify dl_list_for_each() to not use unaligned access with WPA_TRACE
UBSan testing with WPA_TRACE=y ended up hitting an unaligned access for struct os_alloc_trace in os_program_deinit() because of the dl_list_for_each() design that looked like dereferencing the member element of the list head which is something that does not exist. Get the first entry from the list using dl_list_first() so that the empty list special case is covefred and compare item pointers instead of struct dl_list pointers to check whether the end of the loop has been reached. Signed-off-by: Jouni Malinen <j@w1.fi>
-rw-r--r--src/utils/list.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/utils/list.h b/src/utils/list.h
index ee2f485..85aa5e3 100644
--- a/src/utils/list.h
+++ b/src/utils/list.h
@@ -1,6 +1,6 @@
/*
* Doubly-linked list
- * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2009-2019, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
@@ -76,8 +76,8 @@ static inline unsigned int dl_list_len(struct dl_list *list)
dl_list_entry((list)->prev, type, member))
#define dl_list_for_each(item, list, type, member) \
- for (item = dl_list_entry((list)->next, type, member); \
- &item->member != (list); \
+ for (item = dl_list_first((list), type, member); \
+ item && item != dl_list_entry((list), type, member); \
item = dl_list_entry(item->member.next, type, member))
#define dl_list_for_each_safe(item, n, list, type, member) \