public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Marcelo Ricardo Leitner <marcelo.leitner@gmail•com>
To: Xin Long <lucien.xin@gmail•com>,
	network dev <netdev@vger•kernel.org>,
	linux-sctp@vger•kernel.org
Cc: vyasevic@redhat•com, davem@davemloft•net
Subject: Re: [PATCH net] sctp: only drop the reference on the datamsg after sending a msg
Date: Sat, 5 Dec 2015 08:31:11 -0200	[thread overview]
Message-ID: <5662BCEF.3030909@gmail.com> (raw)
In-Reply-To: <b2b92ed429c3f617f5a22df8b232cf58ab7a0fb5.1449299967.git.lucien.xin@gmail.com>

Em 05-12-2015 05:19, Xin Long escreveu:
> 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 <lucien.xin@gmail•com>
> Marcelo Ricardo Leitner <marcelo.leitner@gmail•com>

Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail•com>

Thanks Xin

> ---
>   net/sctp/socket.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index 03c8256..d8460be 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -1966,15 +1966,13 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len)
>   	 * breaks.
>   	 */
>   	err = sctp_primitive_SEND(net, asoc, datamsg);
> +	sctp_datamsg_put(datamsg);
>   	/* Did the lower layer accept the chunk? */
> -	if (err) {
> -		sctp_datamsg_free(datamsg);
> +	if (err)
>   		goto out_free;
> -	}
>
>   	pr_debug("%s: we sent primitively\n", __func__);
>
> -	sctp_datamsg_put(datamsg);
>   	err = msg_len;
>
>   	if (unlikely(wait_connect)) {
>

  reply	other threads:[~2015-12-05 10:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-05  7:19 [PATCH net] sctp: only drop the reference on the datamsg after sending a msg Xin Long
2015-12-05 10:31 ` Marcelo Ricardo Leitner [this message]
2015-12-06 18:26 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5662BCEF.3030909@gmail.com \
    --to=marcelo.leitner@gmail$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=linux-sctp@vger$(echo .)kernel.org \
    --cc=lucien.xin@gmail$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=vyasevic@redhat$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox