Skip to content

Commit e15e067

Browse files
committed
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>
1 parent 348bbc2 commit e15e067

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

net/sctp/stream_interleave.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ static void sctp_intl_store_ordered(struct sctp_ulpq *ulpq,
390390
struct sctp_ulpevent *event)
391391
{
392392
struct sctp_ulpevent *cevent;
393-
struct sk_buff *pos;
393+
struct sk_buff *pos, *loc;
394394

395395
pos = skb_peek_tail(&ulpq->lobby);
396396
if (!pos) {
@@ -410,18 +410,25 @@ static void sctp_intl_store_ordered(struct sctp_ulpq *ulpq,
410410
return;
411411
}
412412

413+
loc = NULL;
413414
skb_queue_walk(&ulpq->lobby, pos) {
414415
cevent = (struct sctp_ulpevent *)pos->cb;
415416

416-
if (cevent->stream > event->stream)
417+
if (cevent->stream > event->stream) {
418+
loc = pos;
417419
break;
418-
420+
}
419421
if (cevent->stream == event->stream &&
420-
MID_lt(event->mid, cevent->mid))
422+
MID_lt(event->mid, cevent->mid)) {
423+
loc = pos;
421424
break;
425+
}
422426
}
423427

424-
__skb_queue_before(&ulpq->lobby, pos, sctp_event2skb(event));
428+
if (!loc)
429+
__skb_queue_tail(&ulpq->lobby, sctp_event2skb(event));
430+
else
431+
__skb_queue_before(&ulpq->lobby, loc, sctp_event2skb(event));
425432
}
426433

427434
static void sctp_intl_retrieve_ordered(struct sctp_ulpq *ulpq,

0 commit comments

Comments
 (0)