diff --git a/lib/typesafe.h b/lib/typesafe.h index 06fdc52e78..df963f530d 100644 --- a/lib/typesafe.h +++ b/lib/typesafe.h @@ -309,7 +309,8 @@ static inline void typesafe_dlist_add(struct dlist_head *head, struct dlist_item *prev, struct dlist_item *item) { item->next = prev->next; - item->next->prev = item; + if (item->next) + item->next->prev = item; item->prev = prev; prev->next = item; head->count++;