Merge branch 'stable-3.2' into pandora-3.2
[pandora-kernel.git] / net / sctp / sm_make_chunk.c
index 743a644..89d03af 100644 (file)
@@ -1324,10 +1324,14 @@ struct sctp_chunk *sctp_make_chunk(const struct sctp_association *asoc,
        sctp_chunkhdr_t *chunk_hdr;
        struct sk_buff *skb;
        struct sock *sk;
+       int chunklen;
+
+       chunklen = WORD_ROUND(sizeof(*chunk_hdr) + paylen);
+       if (chunklen > SCTP_MAX_CHUNK_LEN)
+               goto nodata;
 
        /* No need to allocate LL here, as this is only a chunk. */
-       skb = alloc_skb(WORD_ROUND(sizeof(sctp_chunkhdr_t) + paylen),
-                       GFP_ATOMIC);
+       skb = alloc_skb(chunklen, GFP_ATOMIC);
        if (!skb)
                goto nodata;