Skip to contentSkip to conversation

net: sctp: clear current outbound stream on stream teardown

PATCH In review Ren Wei 2 participants 2 messages May 27 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Ren Wei

author
#1 lore raw

PATCH 1/1 net: sctp: clear current outbound stream on stream teardown

From: Yuqi Xu <[email protected]>

out_curr caches the outbound stream selected for continuing a fragmented message. That pointer refers directly to an entry in the stream->out table.

When the stream table is torn down, such as during stream updates for association restart handling, the old outbound stream entries are freed before a new table is installed. Clear out_curr as part of sctp_stream_free() so later dequeue paths never keep following a stale stream pointer after the teardown.

This keeps the lifetime rule local to the stream teardown helper and covers every current caller that frees the outbound stream table.

Fixes 5bbbbe32a431 ("sctp: introduce stream scheduler foundations")
Assisted-by Codex:GPT-5.4
---
 net/sctp/stream.c | 1 +
 1 file changed, 1 insertion(+)
net/sctp/stream.c +1 -0
index c2247793c88b..207e0a77f9af 100644
@@ -186,6 +186,7 @@ void sctp_stream_free(struct sctp_stream *stream)
 	int i;
 
 	sched->unsched_all(stream);
+	stream->out_curr = NULL;
 	for (i = 0; i < stream->outcnt; i++)
 		sctp_stream_free_ext(stream, i);
 	genradix_free(&stream->out);
Signature · 1 line
2.54.0
maintainer
#2 lore raw
Quoted 35 lines · Ren Wei

From: Yuqi Xu <[email protected]>

out_curr caches the outbound stream selected for continuing a fragmented message. That pointer refers directly to an entry in the stream->out table.

When the stream table is torn down, such as during stream updates for association restart handling, the old outbound stream entries are freed before a new table is installed. Clear out_curr as part of sctp_stream_free() so later dequeue paths never keep following a stale stream pointer after the teardown.

This keeps the lifetime rule local to the stream teardown helper and covers every current caller that frees the outbound stream table.

Fixes 5bbbbe32a431 ("sctp: introduce stream scheduler foundations")
Assisted-by Codex:GPT-5.4
---
 net/sctp/stream.c | 1 +
 1 file changed, 1 insertion(+)
net/sctp/stream.c +0 -0
index c2247793c88b..207e0a77f9af 100644

net/sctp/stream.c void sctp_stream_free(struct sctp_stream *stream) · line 192

Quoted 7 lines
net/sctp/stream.c +1 -0
@@ -186,6 +186,7 @@ void sctp_stream_free(struct sctp_stream *stream)
        int i;
 
        sched->unsched_all(stream);
+       stream->out_curr = NULL;
        for (i = 0; i < stream->outcnt; i++)
                sctp_stream_free_ext(stream, i);
        genradix_free(&stream->out);

As commented on another patch, purging outqueue will also clear stream->out_curr for the corner case via:

sctp_outq_teardown() -> sctp_sched_dequeue_done(last_chunk).

so there's no need to do it here.

Thanks.