netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <erik.hugne@ericsson.com>
To: <netdev@vger.kernel.org>, <tipc-discussion@lists.sourceforge.net>,
	<jon.maloy@ericsson.com>, <maloy@donjonn.com>
Cc: richard.alpe@ericsson.com
Subject: [PATCH net-next v2 2/6] tipc: fix connection refcount leak
Date: Wed, 5 Mar 2014 08:56:14 +0100	[thread overview]
Message-ID: <1394006178-23966-3-git-send-email-erik.hugne@ericsson.com> (raw)
In-Reply-To: <1394006178-23966-1-git-send-email-erik.hugne@ericsson.com>

From: Ying Xue <ying.xue@windriver.com>

When tipc_conn_sendmsg() calls tipc_conn_lookup() to query a
connection instance, its reference count value is increased if
it's found. But subsequently if it's found that the connection is
closed, the work of sending message is not queued into its server
send workqueue, and the connection reference count is not decreased.
This will cause a reference count leak. To reproduce this problem,
an application would need to open and closes topology server
connections with high intensity.

We fix this by immediately decrementing the connection reference
count if a send fails due to the connection being closed.

Signed-off-by: Ying Xue <ying.xue@windriver.com>
Acked-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
---
 net/tipc/server.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/tipc/server.c b/net/tipc/server.c
index 91423ca..0eb6301 100644
--- a/net/tipc/server.c
+++ b/net/tipc/server.c
@@ -430,10 +430,12 @@ int tipc_conn_sendmsg(struct tipc_server *s, int conid,
 	list_add_tail(&e->list, &con->outqueue);
 	spin_unlock_bh(&con->outqueue_lock);
 
-	if (test_bit(CF_CONNECTED, &con->flags))
+	if (test_bit(CF_CONNECTED, &con->flags)) {
 		if (!queue_work(s->send_wq, &con->swork))
 			conn_put(con);
-
+	} else {
+		conn_put(con);
+	}
 	return 0;
 }
 
-- 
1.8.3.2


------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works. 
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk

  parent reply	other threads:[~2014-03-05  7:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-05  7:56 [PATCH net-next v2 0/6] tipc: refcount and memory leak fixes erik.hugne
2014-03-05  7:56 ` [PATCH net-next v2 1/6] tipc: allow connection shutdown callback to be invoked in advance erik.hugne
2014-03-06  4:56   ` David Miller
2014-03-06  9:06     ` Erik Hugne
2014-03-09 17:48       ` Ben Hutchings
2014-03-05  7:56 ` erik.hugne [this message]
2014-03-05  7:56 ` [PATCH net-next v2 3/6] tipc: avoid to unnecessary process switch under non-block mode erik.hugne
2014-03-05  7:56 ` [PATCH net-next v2 4/6] tipc: drop subscriber connection id invalidation erik.hugne
2014-03-05  7:56 ` [PATCH net-next v2 5/6] tipc: fix memory leak during module removal erik.hugne
2014-03-05  7:56 ` [PATCH net-next v2 6/6] tipc: don't log disabled tasklet handler errors erik.hugne

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=1394006178-23966-3-git-send-email-erik.hugne@ericsson.com \
    --to=erik.hugne@ericsson.com \
    --cc=jon.maloy@ericsson.com \
    --cc=maloy@donjonn.com \
    --cc=netdev@vger.kernel.org \
    --cc=richard.alpe@ericsson.com \
    --cc=tipc-discussion@lists.sourceforge.net \
    /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).