Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3421fb15 authored by tsutomu.owa@toshiba.co.jp's avatar tsutomu.owa@toshiba.co.jp Committed by David Teigland
Browse files

DLM: fix memory leak in tcp_accept_from_sock()



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().

Signed-off-by: default avatarTadashi Miyauchi <miyauchi@toshiba-tops.co.jp>
Signed-off-by: default avatarTsutomu Owa <tsutomu.owa@toshiba.co.jp>
Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
parent 294e7e45
Loading
Loading
Loading
Loading
+7 −14
Original line number Diff line number Diff line
@@ -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_lite(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, true);
	result = kernel_accept(con->sock, &newsock, O_NONBLOCK);
	if (result < 0)
		goto accept_err;

@@ -844,6 +836,7 @@ static int tcp_accept_from_sock(struct connection *con)

accept_err:
	mutex_unlock(&con->sock_mutex);
	if (newsock)
		sock_release(newsock);

	if (result != -EAGAIN)