]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
tipc: eliminate buffer leak in bearer layer
authorJon Paul Maloy <jon.maloy@ericsson.com>
Thu, 7 Apr 2016 14:09:13 +0000 (10:09 -0400)
committerDavid S. Miller <davem@davemloft.net>
Thu, 7 Apr 2016 21:00:13 +0000 (17:00 -0400)
commit4e801fa14f68223d36480bced975ebf0c5f9a284
tree01b0373d98b732f1fb29a6e6721b5dc95fe02938
parentba35855e24d12d872e6173692bc34d48d96db39c
tipc: eliminate buffer leak in bearer layer

When enabling a bearer we create a 'neigbor discoverer' instance by
calling the function tipc_disc_create() before the bearer is actually
registered in the list of enabled bearers. Because of this, the very
first discovery broadcast message, created by the mentioned function,
is lost, since it cannot find any valid bearer to use. Furthermore,
the used send function, tipc_bearer_xmit_skb() does not free the given
buffer when it cannot find a  bearer, resulting in the leak of exactly
one send buffer each time a bearer is enabled.

This commit fixes this problem by introducing two changes:

1) Instead of attemting to send the discovery message directly, we let
   tipc_disc_create() return the discovery buffer to the calling
   function, tipc_enable_bearer(), so that the latter can send it
   when the enabling sequence is finished.

2) In tipc_bearer_xmit_skb(), as well as in the two other transmit
   functions at the bearer layer, we now free the indicated buffer or
   buffer chain when a valid bearer cannot be found.

Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/bearer.c
net/tipc/discover.c
net/tipc/discover.h