Skip to content

Commit 8b570dc

Browse files
lxindavem330
authored andcommitted
sctp: only drop the reference on the datamsg after sending a msg
If the chunks are enqueued successfully but sctp_cmd_interpreter() return err to sctp_sendmsg() (mainly because of no mem), the chunks will get re-queued, but we are dropping the reference and freeing them. The fix is to just drop the reference on the datamsg just as it had succeeded, as: - if the chunks weren't queued, this is enough to get them freed. - if they were queued, they will get freed when they finally get out or discarded. Signed-off-by: Xin Long <[email protected]> Marcelo Ricardo Leitner <[email protected]> Signed-off-by: Marcelo Ricardo Leitner <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 69b5777 commit 8b570dc

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

net/sctp/socket.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,15 +1964,13 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len)
19641964
* breaks.
19651965
*/
19661966
err = sctp_primitive_SEND(net, asoc, datamsg);
1967+
sctp_datamsg_put(datamsg);
19671968
/* Did the lower layer accept the chunk? */
1968-
if (err) {
1969-
sctp_datamsg_free(datamsg);
1969+
if (err)
19701970
goto out_free;
1971-
}
19721971

19731972
pr_debug("%s: we sent primitively\n", __func__);
19741973

1975-
sctp_datamsg_put(datamsg);
19761974
err = msg_len;
19771975

19781976
if (unlikely(wait_connect)) {

0 commit comments

Comments
 (0)