diff options
| -rw-r--r-- | net/batman-adv/gateway_client.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index c835e137423b..90cff585b37d 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c | |||
| @@ -42,8 +42,10 @@ | |||
| 42 | 42 | ||
| 43 | static void batadv_gw_node_free_ref(struct batadv_gw_node *gw_node) | 43 | static void batadv_gw_node_free_ref(struct batadv_gw_node *gw_node) |
| 44 | { | 44 | { |
| 45 | if (atomic_dec_and_test(&gw_node->refcount)) | 45 | if (atomic_dec_and_test(&gw_node->refcount)) { |
| 46 | batadv_orig_node_free_ref(gw_node->orig_node); | ||
| 46 | kfree_rcu(gw_node, rcu); | 47 | kfree_rcu(gw_node, rcu); |
| 48 | } | ||
| 47 | } | 49 | } |
| 48 | 50 | ||
| 49 | static struct batadv_gw_node * | 51 | static struct batadv_gw_node * |
| @@ -406,9 +408,14 @@ static void batadv_gw_node_add(struct batadv_priv *bat_priv, | |||
| 406 | if (gateway->bandwidth_down == 0) | 408 | if (gateway->bandwidth_down == 0) |
| 407 | return; | 409 | return; |
| 408 | 410 | ||
| 411 | if (!atomic_inc_not_zero(&orig_node->refcount)) | ||
| 412 | return; | ||
| 413 | |||
| 409 | gw_node = kzalloc(sizeof(*gw_node), GFP_ATOMIC); | 414 | gw_node = kzalloc(sizeof(*gw_node), GFP_ATOMIC); |
| 410 | if (!gw_node) | 415 | if (!gw_node) { |
| 416 | batadv_orig_node_free_ref(orig_node); | ||
| 411 | return; | 417 | return; |
| 418 | } | ||
| 412 | 419 | ||
| 413 | INIT_HLIST_NODE(&gw_node->list); | 420 | INIT_HLIST_NODE(&gw_node->list); |
| 414 | gw_node->orig_node = orig_node; | 421 | gw_node->orig_node = orig_node; |
