[PATCH 5.4 007/214] net: sctp: Fix negotiation of the number of data streams.

From: Greg Kroah-Hartman
Date: Tue Sep 01 2020 - 11:31:18 EST


From: David Laight <David.Laight@xxxxxxxxxx>

[ Upstream commit ab921f3cdbec01c68705a7ade8bec628d541fc2b ]

The number of output and input streams was never being reduced, eg when
processing received INIT or INIT_ACK chunks.
The effect is that DATA chunks can be sent with invalid stream ids
and then discarded by the remote system.

Fixes: 2075e50caf5ea ("sctp: convert to genradix")
Signed-off-by: David Laight <david.laight@xxxxxxxxxx>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@xxxxxxxxx>
Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
net/sctp/stream.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

--- a/net/sctp/stream.c
+++ b/net/sctp/stream.c
@@ -88,12 +88,13 @@ static int sctp_stream_alloc_out(struct
int ret;

if (outcnt <= stream->outcnt)
- return 0;
+ goto out;

ret = genradix_prealloc(&stream->out, outcnt, gfp);
if (ret)
return ret;

+out:
stream->outcnt = outcnt;
return 0;
}
@@ -104,12 +105,13 @@ static int sctp_stream_alloc_in(struct s
int ret;

if (incnt <= stream->incnt)
- return 0;
+ goto out;

ret = genradix_prealloc(&stream->in, incnt, gfp);
if (ret)
return ret;

+out:
stream->incnt = incnt;
return 0;
}