Skip to content

Commit

Permalink
tipc: fix connection refcount leak
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Ying Xue authored and David S. Miller committed Mar 6, 2014
1 parent 6d4ebeb commit 4652edb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions net/tipc/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,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;
}

Expand Down

0 comments on commit 4652edb

Please sign in to comment.