]> git.baikalelectronics.ru Git - kernel.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)
commitc166550ca6f41840c367f46b38881bf3e8f1139b
tree01b0373d98b732f1fb29a6e6721b5dc95fe02938
parent2b4b34d2273c6308a93c128258bf272e31ea6aef
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