From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 14/17] dlm: fix memory leak in tcp_accept_from_sock()
Date: Wed, 9 Aug 2017 12:26:18 +0100 [thread overview]
Message-ID: <a06b4528-d3d2-ee2b-2d17-56c6b2dde53e@redhat.com> (raw)
In-Reply-To: <02d3b9a00fcb42a380b2cafd6fdde2e2@TGXML394.toshiba.local>
Hi,
On 09/08/17 06:51, tsutomu.owa at toshiba.co.jp wrote:
> The sk member of the socket generated by sock_create_kern() is overwritten
> by ops->accept(). So the previous sk will not be released.
> We use kernel_accept() instead of sock_create_kern() and ops->accept().
Yes, that is a better solution than the open coded fix that was proposed
recently. Looks good to me,
Steve.
>
> Signed-off-by: Tadashi Miyauchi <miyauchi@toshiba-tops.co.jp>
> Signed-off-by: Tsutomu Owa <tsutomu.owa@toshiba.co.jp>
> ---
> fs/dlm/lowcomms.c | 21 +++++++--------------
> 1 file changed, 7 insertions(+), 14 deletions(-)
>
> diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
> index 74ed41e..3e7c096 100644
> --- a/fs/dlm/lowcomms.c
> +++ b/fs/dlm/lowcomms.c
> @@ -732,22 +732,14 @@ static int tcp_accept_from_sock(struct connection *con)
> }
> mutex_unlock(&connections_lock);
>
> - memset(&peeraddr, 0, sizeof(peeraddr));
> - result = sock_create_kern(&init_net, dlm_local_addr[0]->ss_family,
> - SOCK_STREAM, IPPROTO_TCP, &newsock);
> - if (result < 0)
> - return -ENOMEM;
> -
> mutex_lock_nested(&con->sock_mutex, 0);
>
> - result = -ENOTCONN;
> - if (con->sock == NULL)
> - goto accept_err;
> -
> - newsock->type = con->sock->type;
> - newsock->ops = con->sock->ops;
> + if (!con->sock) {
> + mutex_unlock(&con->sock_mutex);
> + return -ENOTCONN;
> + }
>
> - result = con->sock->ops->accept(con->sock, newsock, O_NONBLOCK);
> + result = kernel_accept(con->sock, &newsock, O_NONBLOCK);
> if (result < 0)
> goto accept_err;
>
> @@ -844,7 +836,8 @@ static int tcp_accept_from_sock(struct connection *con)
>
> accept_err:
> mutex_unlock(&con->sock_mutex);
> - sock_release(newsock);
> + if (newsock)
> + sock_release(newsock);
>
> if (result != -EAGAIN)
> log_print("error accepting connection from node: %d", result);
prev parent reply other threads:[~2017-08-09 11:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-09 5:51 [Cluster-devel] [PATCH 14/17] dlm: fix memory leak in tcp_accept_from_sock() tsutomu.owa
2017-08-09 11:26 ` Steven Whitehouse [this message]
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=a06b4528-d3d2-ee2b-2d17-56c6b2dde53e@redhat.com \
--to=swhiteho@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).