batman-adv: increase orig refcount when storing ref in gw_node
authorAntonio Quartulli <antonio@open-mesh.com>
Thu, 1 May 2014 23:35:13 +0000 (01:35 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 May 2014 20:20:39 +0000 (13:20 -0700)
commit32eb568e09bfdf10bd90c8478e5a79b5f9f3c841
tree3715c12508ff74eeeb7f067115ae588ee3d14777
parente450a9b46e0d1c6d0b94a63d0d5fd4273d45de24
batman-adv: increase orig refcount when storing ref in gw_node

[ Upstream commit 377fe0f968b30a1a714fab53a908061914f30e26 ]

A pointer to the orig_node representing a bat-gateway is
stored in the gw_node->orig_node member, but the refcount
for such orig_node is never increased.
This leads to memory faults when gw_node->orig_node is accessed
and the originator has already been freed.

Fix this by increasing the refcount on gw_node creation
and decreasing it on gw_node free.

Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/batman-adv/gateway_client.c