* [PATCH net] sctp: only drop the reference on the datamsg after sending a msg
@ 2015-12-05 7:19 ` Xin Long
0 siblings, 0 replies; 6+ messages in thread
From: Xin Long @ 2015-12-05 7:19 UTC (permalink / raw)
To: network dev, linux-sctp; +Cc: marcelo.leitner, vyasevic, davem
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>
---
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)) {
--
2.1.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net] sctp: only drop the reference on the datamsg after sending a msg
@ 2015-12-05 7:19 ` Xin Long
0 siblings, 0 replies; 6+ messages in thread
From: Xin Long @ 2015-12-05 7:19 UTC (permalink / raw)
To: network dev, linux-sctp; +Cc: marcelo.leitner, vyasevic, davem
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>
---
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)) {
--
2.1.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net] sctp: only drop the reference on the datamsg after sending a msg
2015-12-05 7:19 ` Xin Long
@ 2015-12-05 10:31 ` Marcelo Ricardo Leitner
-1 siblings, 0 replies; 6+ messages in thread
From: Marcelo Ricardo Leitner @ 2015-12-05 10:31 UTC (permalink / raw)
To: Xin Long, network dev, linux-sctp; +Cc: vyasevic, davem
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)) {
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net] sctp: only drop the reference on the datamsg after sending a msg
@ 2015-12-05 10:31 ` Marcelo Ricardo Leitner
0 siblings, 0 replies; 6+ messages in thread
From: Marcelo Ricardo Leitner @ 2015-12-05 10:31 UTC (permalink / raw)
To: Xin Long, network dev, linux-sctp; +Cc: vyasevic, davem
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)) {
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net] sctp: only drop the reference on the datamsg after sending a msg
2015-12-05 7:19 ` Xin Long
@ 2015-12-06 18:26 ` David Miller
-1 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2015-12-06 18:26 UTC (permalink / raw)
To: lucien.xin; +Cc: netdev, linux-sctp, marcelo.leitner, vyasevic
From: Xin Long <lucien.xin@gmail.com>
Date: Sat, 5 Dec 2015 15:19:27 +0800
> 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>
Applied.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net] sctp: only drop the reference on the datamsg after sending a msg
@ 2015-12-06 18:26 ` David Miller
0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2015-12-06 18:26 UTC (permalink / raw)
To: lucien.xin; +Cc: netdev, linux-sctp, marcelo.leitner, vyasevic
From: Xin Long <lucien.xin@gmail.com>
Date: Sat, 5 Dec 2015 15:19:27 +0800
> 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>
Applied.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-12-06 18:26 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-05 7:19 [PATCH net] sctp: only drop the reference on the datamsg after sending a msg Xin Long
2015-12-05 7:19 ` Xin Long
2015-12-05 10:31 ` Marcelo Ricardo Leitner
2015-12-05 10:31 ` Marcelo Ricardo Leitner
2015-12-06 18:26 ` David Miller
2015-12-06 18:26 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.