diff options
author | Mark Stapp <mjs@voltanet.io> | 2019-10-16 14:51:43 +0200 |
---|---|---|
committer | Mark Stapp <mjs@voltanet.io> | 2019-10-16 17:01:41 +0200 |
commit | bd2b75a21e20bcf377d6bc2e30517d5c9072c287 (patch) | |
tree | 0dbbab7370330134dc420a8294714dab19b4080c /nhrpd | |
parent | Merge pull request #5156 from donaldsharp/soft_reconfig_the_peer (diff) | |
download | frr-bd2b75a21e20bcf377d6bc2e30517d5c9072c287.tar.xz frr-bd2b75a21e20bcf377d6bc2e30517d5c9072c287.zip |
nhrpd: be more careful with linked lists
NHRPD has its own linked-list implementation, and one of the
apis is a little free and easy with pointers. Also be safer
with one list iteration operation.
Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'nhrpd')
-rw-r--r-- | nhrpd/list.h | 3 | ||||
-rw-r--r-- | nhrpd/nhrpd.h | 6 |
2 files changed, 6 insertions, 3 deletions
diff --git a/nhrpd/list.h b/nhrpd/list.h index ee7f1c440..590d92560 100644 --- a/nhrpd/list.h +++ b/nhrpd/list.h @@ -199,7 +199,8 @@ static inline int list_empty(const struct list_head *n) #define list_for_each_entry_safe(pos, n, head, member) \ for (pos = list_entry((head)->next, typeof(*pos), member), \ - n = list_entry(pos->member.next, typeof(*pos), member); \ + n = (&pos->member != (head) ? \ + list_entry(pos->member.next, typeof(*pos), member) : NULL); \ &pos->member != (head); \ pos = n, n = list_entry(n->member.next, typeof(*n), member)) diff --git a/nhrpd/nhrpd.h b/nhrpd/nhrpd.h index 50746d9ad..ad38cad83 100644 --- a/nhrpd/nhrpd.h +++ b/nhrpd/nhrpd.h @@ -76,8 +76,10 @@ static inline void notifier_del(struct notifier_block *n) static inline void notifier_call(struct notifier_list *l, int cmd) { struct notifier_block *n, *nn; - list_for_each_entry_safe(n, nn, &l->notifier_head, notifier_entry) - n->action(n, cmd); + list_for_each_entry_safe(n, nn, &l->notifier_head, notifier_entry) { + if (n) + n->action(n, cmd); + } } static inline int notifier_active(struct notifier_list *l) |