summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGeoff Levand <geoff@infradead.org>2013-04-23 20:41:07 -0700
committerGeoff Levand <geoff@infradead.org>2013-04-23 20:41:07 -0700
commite0040f05dd45c84214bfdef5d4c6eacf9586aa7b (patch)
treea5540b934ae3d5a07fdbd8255cf20181351c4d0b /lib
parentb211fabbff1c5af472ca07ee5dfdbbe11fc6898f (diff)
downloadtalos-petitboot-e0040f05dd45c84214bfdef5d4c6eacf9586aa7b.tar.gz
talos-petitboot-e0040f05dd45c84214bfdef5d4c6eacf9586aa7b.zip
list: Fix seg fault with list_for_each_entry_safe
Signed-off-by: Geoff Levand <geoff@infradead.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/list/list.h12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/list/list.h b/lib/list/list.h
index 97fb615..6000320 100644
--- a/lib/list/list.h
+++ b/lib/list/list.h
@@ -41,13 +41,11 @@ struct list {
for (; _pos; _pos = list_next_entry(_list, _pos, _member))
#define list_for_each_entry_safe(_list, _pos, _tmp, _member) \
- for (_pos = container_of((_list)->head.next, typeof(*_pos), _member), \
- _tmp = container_of(_pos->_member.next, typeof(*_pos), \
- _member); \
- &_pos->_member != &(_list)->head; \
- _pos = _tmp, \
- _tmp = list_entry(_tmp->_member.next, typeof(*_pos), \
- _member, _list))
+ for (_pos = list_entry((_list)->head.next, typeof(*_pos), _member, _list), \
+ _tmp = list_entry(_pos->_member.next, typeof(*_pos), _member, _list); \
+ _pos; \
+ _pos = _tmp, \
+ _tmp = _tmp ? list_entry(_tmp->_member.next, typeof(*_pos), _member, _list) : NULL)
#define DEFINE_LIST(_list) struct list _list = { \
.head = { \
OpenPOWER on IntegriCloud