diff options
author | David S. Miller <davem@davemloft.net> | 2018-11-10 19:32:23 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-11-10 19:32:23 -0800 |
commit | e15e067d0656625c77c52b4e5f0cfbf0c0c3583f (patch) | |
tree | d06dda58359ade7f684f10eb696a99ff56126cda /net | |
parent | 348bbc25c40844c5efa083a3842c7f53d70a815e (diff) | |
download | linux-e15e067d0656625c77c52b4e5f0cfbf0c0c3583f.tar.gz linux-e15e067d0656625c77c52b4e5f0cfbf0c0c3583f.tar.bz2 linux-e15e067d0656625c77c52b4e5f0cfbf0c0c3583f.zip |
sctp: Fix SKB list traversal in sctp_intl_store_ordered().
Same change as made to sctp_intl_store_reasm().
To be fully correct, an iterator has an undefined value when something
like skb_queue_walk() naturally terminates.
This will actually matter when SKB queues are converted over to
list_head.
Formalize what this code ends up doing with the current
implementation.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/sctp/stream_interleave.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/net/sctp/stream_interleave.c b/net/sctp/stream_interleave.c index 368d9c33fde1..2b499a85db0e 100644 --- a/net/sctp/stream_interleave.c +++ b/net/sctp/stream_interleave.c @@ -390,7 +390,7 @@ static void sctp_intl_store_ordered(struct sctp_ulpq *ulpq, struct sctp_ulpevent *event) { struct sctp_ulpevent *cevent; - struct sk_buff *pos; + struct sk_buff *pos, *loc; pos = skb_peek_tail(&ulpq->lobby); if (!pos) { @@ -410,18 +410,25 @@ static void sctp_intl_store_ordered(struct sctp_ulpq *ulpq, return; } + loc = NULL; skb_queue_walk(&ulpq->lobby, pos) { cevent = (struct sctp_ulpevent *)pos->cb; - if (cevent->stream > event->stream) + if (cevent->stream > event->stream) { + loc = pos; break; - + } if (cevent->stream == event->stream && - MID_lt(event->mid, cevent->mid)) + MID_lt(event->mid, cevent->mid)) { + loc = pos; break; + } } - __skb_queue_before(&ulpq->lobby, pos, sctp_event2skb(event)); + if (!loc) + __skb_queue_tail(&ulpq->lobby, sctp_event2skb(event)); + else + __skb_queue_before(&ulpq->lobby, loc, sctp_event2skb(event)); } static void sctp_intl_retrieve_ordered(struct sctp_ulpq *ulpq, |