kernel/queue: Fix SLIST_REMOVE macro
This patch adds a missing NULL check of list element.
Without that patch, if somebody wants to remove element which is
not on the list, crash occurs
@@ -158,10 +158,11 @@ struct { \
} \
else { \
struct type *curelm = SLIST_FIRST((head)); \
- while (SLIST_NEXT(curelm, field) != (elm)) \
+ while (SLIST_NEXT(curelm, field) && \
+ SLIST_NEXT(curelm, field) != (elm)) { \
curelm = SLIST_NEXT(curelm, field); \
- SLIST_NEXT(curelm, field) = \
- SLIST_NEXT(SLIST_NEXT(curelm, field), field); \
+ } \
+ SLIST_NEXT(curelm, field) = SLIST_NEXT(elm, field); \
} \
} while (0)
