sctp: fix memory leak in sctp_datamsg_from_user() when copy from user space fails
[deliverable/linux.git] / net / sctp / chunk.c
index 7c2df9c33df37a588c426e7945cd71233edd4577..f2aebdbb1eda3d28334d54af8d9861e7c9728a5e 100644 (file)
@@ -284,7 +284,7 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
                        goto errout;
                err = sctp_user_addto_chunk(chunk, offset, len, msgh->msg_iov);
                if (err < 0)
-                       goto errout;
+                       goto errout_chunk_free;
 
                offset += len;
 
@@ -324,7 +324,7 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
                __skb_pull(chunk->skb, (__u8 *)chunk->chunk_hdr
                           - (__u8 *)chunk->skb->data);
                if (err < 0)
-                       goto errout;
+                       goto errout_chunk_free;
 
                sctp_datamsg_assign(msg, chunk);
                list_add_tail(&chunk->frag_list, &msg->chunks);
@@ -332,6 +332,9 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
 
        return msg;
 
+errout_chunk_free:
+       sctp_chunk_free(chunk);
+
 errout:
        list_for_each_safe(pos, temp, &msg->chunks) {
                list_del_init(pos);
This page took 0.045775 seconds and 5 git commands to generate.