diff options
author | Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> | 2018-04-29 12:56:31 -0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-05-01 12:09:35 -0400 |
commit | 6d3e8aa87622b30bfabbbfad7674d2464f2a9cb9 (patch) | |
tree | 0b133b6911870067b472d9a214d081c0919a11ae /net/sctp/sm_make_chunk.c | |
parent | 065662d941cb85449985d9b5a7cd1cc49676cc79 (diff) | |
download | linux-6d3e8aa87622b30bfabbbfad7674d2464f2a9cb9.tar.gz linux-6d3e8aa87622b30bfabbbfad7674d2464f2a9cb9.tar.bz2 linux-6d3e8aa87622b30bfabbbfad7674d2464f2a9cb9.zip |
sctp: allow sctp_init_cause to return errors
And do so if the skb doesn't have enough space for the payload.
This is a preparation for the next patch.
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp/sm_make_chunk.c')
-rw-r--r-- | net/sctp/sm_make_chunk.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index db93eabd6ef5..e518eb64ccf3 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c @@ -158,8 +158,8 @@ static const struct sctp_paramhdr prsctp_param = { * provided chunk, as most cause codes will be embedded inside an * abort chunk. */ -void sctp_init_cause(struct sctp_chunk *chunk, __be16 cause_code, - size_t paylen) +int sctp_init_cause(struct sctp_chunk *chunk, __be16 cause_code, + size_t paylen) { struct sctp_errhdr err; __u16 len; @@ -167,8 +167,14 @@ void sctp_init_cause(struct sctp_chunk *chunk, __be16 cause_code, /* Cause code constants are now defined in network order. */ err.cause = cause_code; len = sizeof(err) + paylen; - err.length = htons(len); + err.length = htons(len); + + if (skb_tailroom(chunk->skb) < len) + return -ENOSPC; + chunk->subh.err_hdr = sctp_addto_chunk(chunk, sizeof(err), &err); + + return 0; } /* A helper to initialize an op error inside a |