diff options
Diffstat (limited to 'net/sctp/stream.c')
| -rw-r--r-- | net/sctp/stream.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/net/sctp/stream.c b/net/sctp/stream.c index 80e0ae5534ec..2936ed17bf9e 100644 --- a/net/sctp/stream.c +++ b/net/sctp/stream.c | |||
| @@ -84,6 +84,19 @@ static void fa_zero(struct flex_array *fa, size_t index, size_t count) | |||
| 84 | } | 84 | } |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | static size_t fa_index(struct flex_array *fa, void *elem, size_t count) | ||
| 88 | { | ||
| 89 | size_t index = 0; | ||
| 90 | |||
| 91 | while (count--) { | ||
| 92 | if (elem == flex_array_get(fa, index)) | ||
| 93 | break; | ||
| 94 | index++; | ||
| 95 | } | ||
| 96 | |||
| 97 | return index; | ||
| 98 | } | ||
| 99 | |||
| 87 | /* Migrates chunks from stream queues to new stream queues if needed, | 100 | /* Migrates chunks from stream queues to new stream queues if needed, |
| 88 | * but not across associations. Also, removes those chunks to streams | 101 | * but not across associations. Also, removes those chunks to streams |
| 89 | * higher than the new max. | 102 | * higher than the new max. |
| @@ -131,8 +144,10 @@ static void sctp_stream_outq_migrate(struct sctp_stream *stream, | |||
| 131 | } | 144 | } |
| 132 | } | 145 | } |
| 133 | 146 | ||
| 134 | for (i = outcnt; i < stream->outcnt; i++) | 147 | for (i = outcnt; i < stream->outcnt; i++) { |
| 135 | kfree(SCTP_SO(stream, i)->ext); | 148 | kfree(SCTP_SO(stream, i)->ext); |
| 149 | SCTP_SO(stream, i)->ext = NULL; | ||
| 150 | } | ||
| 136 | } | 151 | } |
| 137 | 152 | ||
| 138 | static int sctp_stream_alloc_out(struct sctp_stream *stream, __u16 outcnt, | 153 | static int sctp_stream_alloc_out(struct sctp_stream *stream, __u16 outcnt, |
| @@ -147,6 +162,13 @@ static int sctp_stream_alloc_out(struct sctp_stream *stream, __u16 outcnt, | |||
| 147 | 162 | ||
| 148 | if (stream->out) { | 163 | if (stream->out) { |
| 149 | fa_copy(out, stream->out, 0, min(outcnt, stream->outcnt)); | 164 | fa_copy(out, stream->out, 0, min(outcnt, stream->outcnt)); |
| 165 | if (stream->out_curr) { | ||
| 166 | size_t index = fa_index(stream->out, stream->out_curr, | ||
| 167 | stream->outcnt); | ||
| 168 | |||
| 169 | BUG_ON(index == stream->outcnt); | ||
| 170 | stream->out_curr = flex_array_get(out, index); | ||
| 171 | } | ||
| 150 | fa_free(stream->out); | 172 | fa_free(stream->out); |
| 151 | } | 173 | } |
| 152 | 174 | ||
