Skip to contentSkip to conversation

sctp: stream: clear out_curr when freeing stream data

PATCH In review Ren Wei 1 participant 2 messages May 28 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 sctp: stream: clear out_curr when freeing stream data

From: Yuqi Xu <[email protected]>

out_curr caches the current outbound stream and points into the stream->out storage. Once the stream tables are torn down, that pointer is no longer valid and must not survive the teardown.

sctp_stream_update() frees the old stream tables before installing the new ones. If out_curr still points into the old outbound table, later dequeue paths can continue from stale scheduler state instead of falling back to the normal queue walk.

Clear out_curr in sctp_stream_free(), which owns the lifetime of the stream storage and covers every teardown caller.

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
author
#2 lore raw
Quoted 33 lines · Ren Wei

From: Yuqi Xu <[email protected]>

out_curr caches the current outbound stream and points into the stream->out storage. Once the stream tables are torn down, that pointer is no longer valid and must not survive the teardown.

sctp_stream_update() frees the old stream tables before installing the new ones. If out_curr still points into the old outbound table, later dequeue paths can continue from stale scheduler state instead of falling back to the normal queue walk.

Clear out_curr in sctp_stream_free(), which owns the lifetime of the stream storage and covers every teardown caller.

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);

Sorry for the duplicate posting. I accidentally sent this patch series twice.

Please ignore the extra copy. Apologies for the noise.

Best regards,
Ren Wei