Commit 79a0bffb authored by Sven Eckelmann's avatar Sven Eckelmann Committed by Simon Wunderlich

batman-adv: Drop NULL check before dropping references

The check if a batman-adv related object is NULL or not is now directly in
the batadv_*_put functions. It is not needed anymore to perform this check
outside these function:

The changes were generated using a coccinelle semantic patch:

  @@
  expression E;
  @@
  - if (likely(E != NULL))
  (
  batadv_backbone_gw_put
  |
  batadv_claim_put
  |
  batadv_dat_entry_put
  |
  batadv_gw_node_put
  |
  batadv_hardif_neigh_put
  |
  batadv_hardif_put
  |
  batadv_nc_node_put
  |
  batadv_nc_path_put
  |
  batadv_neigh_ifinfo_put
  |
  batadv_neigh_node_put
  |
  batadv_orig_ifinfo_put
  |
  batadv_orig_node_put
  |
  batadv_orig_node_vlan_put
  |
  batadv_softif_vlan_put
  |
  batadv_tp_vars_put
  |
  batadv_tt_global_entry_put
  |
  batadv_tt_local_entry_put
  |
  batadv_tt_orig_list_entry_put
  |
  batadv_tt_req_node_put
  |
  batadv_tvlv_container_put
  |
  batadv_tvlv_handler_put
  )(E);
Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
Signed-off-by: default avatarSimon Wunderlich <sw@simonwunderlich.de>
parent 6340dcbd
...@@ -519,7 +519,6 @@ batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet, ...@@ -519,7 +519,6 @@ batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet,
} }
out: out:
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
return res; return res;
} }
...@@ -857,7 +856,6 @@ static void batadv_iv_ogm_schedule_buff(struct batadv_hard_iface *hard_iface) ...@@ -857,7 +856,6 @@ static void batadv_iv_ogm_schedule_buff(struct batadv_hard_iface *hard_iface)
rcu_read_unlock(); rcu_read_unlock();
out: out:
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
} }
...@@ -1046,13 +1044,9 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv, ...@@ -1046,13 +1044,9 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
unlock: unlock:
rcu_read_unlock(); rcu_read_unlock();
out: out:
if (neigh_node)
batadv_neigh_node_put(neigh_node); batadv_neigh_node_put(neigh_node);
if (router)
batadv_neigh_node_put(router); batadv_neigh_node_put(router);
if (neigh_ifinfo)
batadv_neigh_ifinfo_put(neigh_ifinfo); batadv_neigh_ifinfo_put(neigh_ifinfo);
if (router_ifinfo)
batadv_neigh_ifinfo_put(router_ifinfo); batadv_neigh_ifinfo_put(router_ifinfo);
} }
...@@ -1194,7 +1188,6 @@ static bool batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node, ...@@ -1194,7 +1188,6 @@ static bool batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node,
ret = true; ret = true;
out: out:
if (neigh_node)
batadv_neigh_node_put(neigh_node); batadv_neigh_node_put(neigh_node);
return ret; return ret;
} }
...@@ -1496,15 +1489,10 @@ batadv_iv_ogm_process_per_outif(const struct sk_buff *skb, int ogm_offset, ...@@ -1496,15 +1489,10 @@ batadv_iv_ogm_process_per_outif(const struct sk_buff *skb, int ogm_offset,
if (orig_neigh_node && !is_single_hop_neigh) if (orig_neigh_node && !is_single_hop_neigh)
batadv_orig_node_put(orig_neigh_node); batadv_orig_node_put(orig_neigh_node);
out: out:
if (router_ifinfo)
batadv_neigh_ifinfo_put(router_ifinfo); batadv_neigh_ifinfo_put(router_ifinfo);
if (router)
batadv_neigh_node_put(router); batadv_neigh_node_put(router);
if (router_router)
batadv_neigh_node_put(router_router); batadv_neigh_node_put(router_router);
if (orig_neigh_router)
batadv_neigh_node_put(orig_neigh_router); batadv_neigh_node_put(orig_neigh_router);
if (hardif_neigh)
batadv_hardif_neigh_put(hardif_neigh); batadv_hardif_neigh_put(hardif_neigh);
consume_skb(skb_priv); consume_skb(skb_priv);
...@@ -1926,7 +1914,6 @@ batadv_iv_ogm_orig_dump_entry(struct sk_buff *msg, u32 portid, u32 seq, ...@@ -1926,7 +1914,6 @@ batadv_iv_ogm_orig_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
} }
out: out:
if (neigh_node_best)
batadv_neigh_node_put(neigh_node_best); batadv_neigh_node_put(neigh_node_best);
*sub_s = 0; *sub_s = 0;
...@@ -2049,9 +2036,7 @@ static bool batadv_iv_ogm_neigh_diff(struct batadv_neigh_node *neigh1, ...@@ -2049,9 +2036,7 @@ static bool batadv_iv_ogm_neigh_diff(struct batadv_neigh_node *neigh1,
*diff = (int)tq1 - (int)tq2; *diff = (int)tq1 - (int)tq2;
out: out:
if (neigh1_ifinfo)
batadv_neigh_ifinfo_put(neigh1_ifinfo); batadv_neigh_ifinfo_put(neigh1_ifinfo);
if (neigh2_ifinfo)
batadv_neigh_ifinfo_put(neigh2_ifinfo); batadv_neigh_ifinfo_put(neigh2_ifinfo);
return ret; return ret;
...@@ -2299,7 +2284,6 @@ batadv_iv_gw_get_best_gw_node(struct batadv_priv *bat_priv) ...@@ -2299,7 +2284,6 @@ batadv_iv_gw_get_best_gw_node(struct batadv_priv *bat_priv)
if (tmp_gw_factor > max_gw_factor || if (tmp_gw_factor > max_gw_factor ||
(tmp_gw_factor == max_gw_factor && (tmp_gw_factor == max_gw_factor &&
tq_avg > max_tq)) { tq_avg > max_tq)) {
if (curr_gw)
batadv_gw_node_put(curr_gw); batadv_gw_node_put(curr_gw);
curr_gw = gw_node; curr_gw = gw_node;
kref_get(&curr_gw->refcount); kref_get(&curr_gw->refcount);
...@@ -2314,7 +2298,6 @@ batadv_iv_gw_get_best_gw_node(struct batadv_priv *bat_priv) ...@@ -2314,7 +2298,6 @@ batadv_iv_gw_get_best_gw_node(struct batadv_priv *bat_priv)
* $routing_class more tq points) * $routing_class more tq points)
*/ */
if (tq_avg > max_tq) { if (tq_avg > max_tq) {
if (curr_gw)
batadv_gw_node_put(curr_gw); batadv_gw_node_put(curr_gw);
curr_gw = gw_node; curr_gw = gw_node;
kref_get(&curr_gw->refcount); kref_get(&curr_gw->refcount);
...@@ -2332,7 +2315,6 @@ batadv_iv_gw_get_best_gw_node(struct batadv_priv *bat_priv) ...@@ -2332,7 +2315,6 @@ batadv_iv_gw_get_best_gw_node(struct batadv_priv *bat_priv)
next: next:
batadv_neigh_node_put(router); batadv_neigh_node_put(router);
if (router_ifinfo)
batadv_neigh_ifinfo_put(router_ifinfo); batadv_neigh_ifinfo_put(router_ifinfo);
} }
rcu_read_unlock(); rcu_read_unlock();
...@@ -2397,13 +2379,9 @@ static bool batadv_iv_gw_is_eligible(struct batadv_priv *bat_priv, ...@@ -2397,13 +2379,9 @@ static bool batadv_iv_gw_is_eligible(struct batadv_priv *bat_priv,
ret = true; ret = true;
out: out:
if (router_gw_ifinfo)
batadv_neigh_ifinfo_put(router_gw_ifinfo); batadv_neigh_ifinfo_put(router_gw_ifinfo);
if (router_orig_ifinfo)
batadv_neigh_ifinfo_put(router_orig_ifinfo); batadv_neigh_ifinfo_put(router_orig_ifinfo);
if (router_gw)
batadv_neigh_node_put(router_gw); batadv_neigh_node_put(router_gw);
if (router_orig)
batadv_neigh_node_put(router_orig); batadv_neigh_node_put(router_orig);
return ret; return ret;
...@@ -2479,11 +2457,8 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid, ...@@ -2479,11 +2457,8 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid,
ret = 0; ret = 0;
out: out:
if (curr_gw)
batadv_gw_node_put(curr_gw); batadv_gw_node_put(curr_gw);
if (router_ifinfo)
batadv_neigh_ifinfo_put(router_ifinfo); batadv_neigh_ifinfo_put(router_ifinfo);
if (router)
batadv_neigh_node_put(router); batadv_neigh_node_put(router);
return ret; return ret;
} }
......
...@@ -106,7 +106,6 @@ static void batadv_v_iface_update_mac(struct batadv_hard_iface *hard_iface) ...@@ -106,7 +106,6 @@ static void batadv_v_iface_update_mac(struct batadv_hard_iface *hard_iface)
batadv_v_primary_iface_set(hard_iface); batadv_v_primary_iface_set(hard_iface);
out: out:
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
} }
...@@ -366,7 +365,6 @@ batadv_v_orig_dump_entry(struct sk_buff *msg, u32 portid, u32 seq, ...@@ -366,7 +365,6 @@ batadv_v_orig_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
} }
out: out:
if (neigh_node_best)
batadv_neigh_node_put(neigh_node_best); batadv_neigh_node_put(neigh_node_best);
*sub_s = 0; *sub_s = 0;
...@@ -568,9 +566,7 @@ static int batadv_v_gw_throughput_get(struct batadv_gw_node *gw_node, u32 *bw) ...@@ -568,9 +566,7 @@ static int batadv_v_gw_throughput_get(struct batadv_gw_node *gw_node, u32 *bw)
ret = 0; ret = 0;
out: out:
if (router)
batadv_neigh_node_put(router); batadv_neigh_node_put(router);
if (router_ifinfo)
batadv_neigh_ifinfo_put(router_ifinfo); batadv_neigh_ifinfo_put(router_ifinfo);
return ret; return ret;
...@@ -599,7 +595,6 @@ batadv_v_gw_get_best_gw_node(struct batadv_priv *bat_priv) ...@@ -599,7 +595,6 @@ batadv_v_gw_get_best_gw_node(struct batadv_priv *bat_priv)
if (curr_gw && bw <= max_bw) if (curr_gw && bw <= max_bw)
goto next; goto next;
if (curr_gw)
batadv_gw_node_put(curr_gw); batadv_gw_node_put(curr_gw);
curr_gw = gw_node; curr_gw = gw_node;
...@@ -662,9 +657,7 @@ static bool batadv_v_gw_is_eligible(struct batadv_priv *bat_priv, ...@@ -662,9 +657,7 @@ static bool batadv_v_gw_is_eligible(struct batadv_priv *bat_priv,
ret = true; ret = true;
out: out:
if (curr_gw)
batadv_gw_node_put(curr_gw); batadv_gw_node_put(curr_gw);
if (orig_gw)
batadv_gw_node_put(orig_gw); batadv_gw_node_put(orig_gw);
return ret; return ret;
...@@ -764,11 +757,8 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, ...@@ -764,11 +757,8 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid,
ret = 0; ret = 0;
out: out:
if (curr_gw)
batadv_gw_node_put(curr_gw); batadv_gw_node_put(curr_gw);
if (router_ifinfo)
batadv_neigh_ifinfo_put(router_ifinfo); batadv_neigh_ifinfo_put(router_ifinfo);
if (router)
batadv_neigh_node_put(router); batadv_neigh_node_put(router);
return ret; return ret;
} }
......
...@@ -486,13 +486,10 @@ static void batadv_v_elp_neigh_update(struct batadv_priv *bat_priv, ...@@ -486,13 +486,10 @@ static void batadv_v_elp_neigh_update(struct batadv_priv *bat_priv,
hardif_neigh->bat_v.elp_interval = ntohl(elp_packet->elp_interval); hardif_neigh->bat_v.elp_interval = ntohl(elp_packet->elp_interval);
hardif_free: hardif_free:
if (hardif_neigh)
batadv_hardif_neigh_put(hardif_neigh); batadv_hardif_neigh_put(hardif_neigh);
neigh_free: neigh_free:
if (neigh)
batadv_neigh_node_put(neigh); batadv_neigh_node_put(neigh);
orig_free: orig_free:
if (orig_neigh)
batadv_orig_node_put(orig_neigh); batadv_orig_node_put(orig_neigh);
} }
......
...@@ -584,11 +584,8 @@ static void batadv_v_ogm_forward(struct batadv_priv *bat_priv, ...@@ -584,11 +584,8 @@ static void batadv_v_ogm_forward(struct batadv_priv *bat_priv,
batadv_v_ogm_queue_on_if(skb, if_outgoing); batadv_v_ogm_queue_on_if(skb, if_outgoing);
out: out:
if (orig_ifinfo)
batadv_orig_ifinfo_put(orig_ifinfo); batadv_orig_ifinfo_put(orig_ifinfo);
if (router)
batadv_neigh_node_put(router); batadv_neigh_node_put(router);
if (neigh_ifinfo)
batadv_neigh_ifinfo_put(neigh_ifinfo); batadv_neigh_ifinfo_put(neigh_ifinfo);
} }
...@@ -669,9 +666,7 @@ static int batadv_v_ogm_metric_update(struct batadv_priv *bat_priv, ...@@ -669,9 +666,7 @@ static int batadv_v_ogm_metric_update(struct batadv_priv *bat_priv,
else else
ret = 0; ret = 0;
out: out:
if (orig_ifinfo)
batadv_orig_ifinfo_put(orig_ifinfo); batadv_orig_ifinfo_put(orig_ifinfo);
if (neigh_ifinfo)
batadv_neigh_ifinfo_put(neigh_ifinfo); batadv_neigh_ifinfo_put(neigh_ifinfo);
return ret; return ret;
...@@ -763,15 +758,10 @@ static bool batadv_v_ogm_route_update(struct batadv_priv *bat_priv, ...@@ -763,15 +758,10 @@ static bool batadv_v_ogm_route_update(struct batadv_priv *bat_priv,
batadv_update_route(bat_priv, orig_node, if_outgoing, neigh_node); batadv_update_route(bat_priv, orig_node, if_outgoing, neigh_node);
out: out:
if (router)
batadv_neigh_node_put(router); batadv_neigh_node_put(router);
if (orig_neigh_router)
batadv_neigh_node_put(orig_neigh_router); batadv_neigh_node_put(orig_neigh_router);
if (orig_neigh_node)
batadv_orig_node_put(orig_neigh_node); batadv_orig_node_put(orig_neigh_node);
if (router_ifinfo)
batadv_neigh_ifinfo_put(router_ifinfo); batadv_neigh_ifinfo_put(router_ifinfo);
if (neigh_ifinfo)
batadv_neigh_ifinfo_put(neigh_ifinfo); batadv_neigh_ifinfo_put(neigh_ifinfo);
return forward; return forward;
...@@ -978,11 +968,8 @@ static void batadv_v_ogm_process(const struct sk_buff *skb, int ogm_offset, ...@@ -978,11 +968,8 @@ static void batadv_v_ogm_process(const struct sk_buff *skb, int ogm_offset,
} }
rcu_read_unlock(); rcu_read_unlock();
out: out:
if (orig_node)
batadv_orig_node_put(orig_node); batadv_orig_node_put(orig_node);
if (neigh_node)
batadv_neigh_node_put(neigh_node); batadv_neigh_node_put(neigh_node);
if (hardif_neigh)
batadv_hardif_neigh_put(hardif_neigh); batadv_hardif_neigh_put(hardif_neigh);
} }
......
...@@ -445,7 +445,6 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, u8 *mac, ...@@ -445,7 +445,6 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, u8 *mac,
netif_rx_any_context(skb); netif_rx_any_context(skb);
out: out:
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
} }
...@@ -1504,7 +1503,6 @@ static void batadv_bla_periodic_work(struct work_struct *work) ...@@ -1504,7 +1503,6 @@ static void batadv_bla_periodic_work(struct work_struct *work)
rcu_read_unlock(); rcu_read_unlock();
} }
out: out:
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work, queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work,
...@@ -1814,7 +1812,6 @@ void batadv_bla_free(struct batadv_priv *bat_priv) ...@@ -1814,7 +1812,6 @@ void batadv_bla_free(struct batadv_priv *bat_priv)
batadv_hash_destroy(bat_priv->bla.backbone_hash); batadv_hash_destroy(bat_priv->bla.backbone_hash);
bat_priv->bla.backbone_hash = NULL; bat_priv->bla.backbone_hash = NULL;
} }
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
} }
...@@ -2002,9 +1999,7 @@ bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, ...@@ -2002,9 +1999,7 @@ bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
ret = true; ret = true;
out: out:
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
if (claim)
batadv_claim_put(claim); batadv_claim_put(claim);
return ret; return ret;
} }
...@@ -2109,9 +2104,7 @@ bool batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, ...@@ -2109,9 +2104,7 @@ bool batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
handled: handled:
ret = true; ret = true;
out: out:
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
if (claim)
batadv_claim_put(claim); batadv_claim_put(claim);
return ret; return ret;
} }
...@@ -2277,7 +2270,6 @@ int batadv_bla_claim_dump(struct sk_buff *msg, struct netlink_callback *cb) ...@@ -2277,7 +2270,6 @@ int batadv_bla_claim_dump(struct sk_buff *msg, struct netlink_callback *cb)
ret = msg->len; ret = msg->len;
out: out:
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
dev_put(soft_iface); dev_put(soft_iface);
...@@ -2448,7 +2440,6 @@ int batadv_bla_backbone_dump(struct sk_buff *msg, struct netlink_callback *cb) ...@@ -2448,7 +2440,6 @@ int batadv_bla_backbone_dump(struct sk_buff *msg, struct netlink_callback *cb)
ret = msg->len; ret = msg->len;
out: out:
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
dev_put(soft_iface); dev_put(soft_iface);
......
...@@ -408,7 +408,6 @@ static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip, ...@@ -408,7 +408,6 @@ static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip,
&dat_entry->ip, dat_entry->mac_addr, batadv_print_vid(vid)); &dat_entry->ip, dat_entry->mac_addr, batadv_print_vid(vid));
out: out:
if (dat_entry)
batadv_dat_entry_put(dat_entry); batadv_dat_entry_put(dat_entry);
} }
...@@ -597,7 +596,6 @@ static void batadv_choose_next_candidate(struct batadv_priv *bat_priv, ...@@ -597,7 +596,6 @@ static void batadv_choose_next_candidate(struct batadv_priv *bat_priv,
continue; continue;
max = tmp_max; max = tmp_max;
if (max_orig_node)
batadv_orig_node_put(max_orig_node); batadv_orig_node_put(max_orig_node);
max_orig_node = orig_node; max_orig_node = orig_node;
} }
...@@ -984,7 +982,6 @@ int batadv_dat_cache_dump(struct sk_buff *msg, struct netlink_callback *cb) ...@@ -984,7 +982,6 @@ int batadv_dat_cache_dump(struct sk_buff *msg, struct netlink_callback *cb)
ret = msg->len; ret = msg->len;
out: out:
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
dev_put(soft_iface); dev_put(soft_iface);
...@@ -1220,7 +1217,6 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv, ...@@ -1220,7 +1217,6 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
BATADV_P_DAT_DHT_GET); BATADV_P_DAT_DHT_GET);
} }
out: out:
if (dat_entry)
batadv_dat_entry_put(dat_entry); batadv_dat_entry_put(dat_entry);
return ret; return ret;
} }
...@@ -1288,7 +1284,6 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv, ...@@ -1288,7 +1284,6 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
ret = true; ret = true;
} }
out: out:
if (dat_entry)
batadv_dat_entry_put(dat_entry); batadv_dat_entry_put(dat_entry);
if (ret) if (ret)
kfree_skb(skb); kfree_skb(skb);
...@@ -1422,7 +1417,6 @@ bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv, ...@@ -1422,7 +1417,6 @@ bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
out: out:
if (dropped) if (dropped)
kfree_skb(skb); kfree_skb(skb);
if (dat_entry)
batadv_dat_entry_put(dat_entry); batadv_dat_entry_put(dat_entry);
/* if dropped == false -> deliver to the interface */ /* if dropped == false -> deliver to the interface */
return dropped; return dropped;
...@@ -1832,7 +1826,6 @@ bool batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv, ...@@ -1832,7 +1826,6 @@ bool batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv,
ret = true; ret = true;
out: out:
if (dat_entry)
batadv_dat_entry_put(dat_entry); batadv_dat_entry_put(dat_entry);
return ret; return ret;
} }
...@@ -381,9 +381,7 @@ bool batadv_frag_skb_fwd(struct sk_buff *skb, ...@@ -381,9 +381,7 @@ bool batadv_frag_skb_fwd(struct sk_buff *skb,
} }
out: out:
if (orig_node_dst)
batadv_orig_node_put(orig_node_dst); batadv_orig_node_put(orig_node_dst);
if (neigh_node)
batadv_neigh_node_put(neigh_node); batadv_neigh_node_put(neigh_node);
return ret; return ret;
} }
......
...@@ -120,7 +120,6 @@ batadv_gw_get_selected_orig(struct batadv_priv *bat_priv) ...@@ -120,7 +120,6 @@ batadv_gw_get_selected_orig(struct batadv_priv *bat_priv)
unlock: unlock:
rcu_read_unlock(); rcu_read_unlock();
out: out:
if (gw_node)
batadv_gw_node_put(gw_node); batadv_gw_node_put(gw_node);
return orig_node; return orig_node;
} }
...@@ -138,7 +137,6 @@ static void batadv_gw_select(struct batadv_priv *bat_priv, ...@@ -138,7 +137,6 @@ static void batadv_gw_select(struct batadv_priv *bat_priv,
curr_gw_node = rcu_replace_pointer(bat_priv->gw.curr_gw, new_gw_node, curr_gw_node = rcu_replace_pointer(bat_priv->gw.curr_gw, new_gw_node,
true); true);
if (curr_gw_node)
batadv_gw_node_put(curr_gw_node); batadv_gw_node_put(curr_gw_node);
spin_unlock_bh(&bat_priv->gw.list_lock); spin_unlock_bh(&bat_priv->gw.list_lock);
...@@ -274,13 +272,9 @@ void batadv_gw_election(struct batadv_priv *bat_priv) ...@@ -274,13 +272,9 @@ void batadv_gw_election(struct batadv_priv *bat_priv)
batadv_gw_select(bat_priv, next_gw); batadv_gw_select(bat_priv, next_gw);
out: out:
if (curr_gw)
batadv_gw_node_put(curr_gw); batadv_gw_node_put(curr_gw);
if (next_gw)
batadv_gw_node_put(next_gw); batadv_gw_node_put(next_gw);
if (router)
batadv_neigh_node_put(router); batadv_neigh_node_put(router);
if (router_ifinfo)
batadv_neigh_ifinfo_put(router_ifinfo); batadv_neigh_ifinfo_put(router_ifinfo);
} }
...@@ -315,7 +309,6 @@ void batadv_gw_check_election(struct batadv_priv *bat_priv, ...@@ -315,7 +309,6 @@ void batadv_gw_check_election(struct batadv_priv *bat_priv,
reselect: reselect:
batadv_gw_reselect(bat_priv); batadv_gw_reselect(bat_priv);
out: out:
if (curr_gw_orig)
batadv_orig_node_put(curr_gw_orig); batadv_orig_node_put(curr_gw_orig);
} }
...@@ -456,12 +449,10 @@ void batadv_gw_node_update(struct batadv_priv *bat_priv, ...@@ -456,12 +449,10 @@ void batadv_gw_node_update(struct batadv_priv *bat_priv,
if (gw_node == curr_gw) if (gw_node == curr_gw)
batadv_gw_reselect(bat_priv); batadv_gw_reselect(bat_priv);
if (curr_gw)
batadv_gw_node_put(curr_gw); batadv_gw_node_put(curr_gw);
} }
out: out:
if (gw_node)
batadv_gw_node_put(gw_node); batadv_gw_node_put(gw_node);
} }
...@@ -545,7 +536,6 @@ int batadv_gw_dump(struct sk_buff *msg, struct netlink_callback *cb) ...@@ -545,7 +536,6 @@ int batadv_gw_dump(struct sk_buff *msg, struct netlink_callback *cb)
ret = msg->len; ret = msg->len;
out: out:
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
dev_put(soft_iface); dev_put(soft_iface);
...@@ -769,15 +759,10 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, ...@@ -769,15 +759,10 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
batadv_neigh_ifinfo_put(old_ifinfo); batadv_neigh_ifinfo_put(old_ifinfo);
out: out:
if (orig_dst_node)
batadv_orig_node_put(orig_dst_node); batadv_orig_node_put(orig_dst_node);
if (curr_gw)
batadv_gw_node_put(curr_gw); batadv_gw_node_put(curr_gw);
if (gw_node)
batadv_gw_node_put(gw_node); batadv_gw_node_put(gw_node);
if (neigh_old)
batadv_neigh_node_put(neigh_old); batadv_neigh_node_put(neigh_old);
if (neigh_curr)
batadv_neigh_node_put(neigh_curr); batadv_neigh_node_put(neigh_curr);
return out_of_range; return out_of_range;
} }
...@@ -236,7 +236,6 @@ static struct net_device *batadv_get_real_netdevice(struct net_device *netdev) ...@@ -236,7 +236,6 @@ static struct net_device *batadv_get_real_netdevice(struct net_device *netdev)
real_netdev = dev_get_by_index(real_net, ifindex); real_netdev = dev_get_by_index(real_net, ifindex);
out: out:
if (hard_iface)
batadv_hardif_put(hard_iface); batadv_hardif_put(hard_iface);
return real_netdev; return real_netdev;
} }
...@@ -457,7 +456,6 @@ static void batadv_primary_if_update_addr(struct batadv_priv *bat_priv, ...@@ -457,7 +456,6 @@ static void batadv_primary_if_update_addr(struct batadv_priv *bat_priv,
batadv_dat_init_own_addr(bat_priv, primary_if); batadv_dat_init_own_addr(bat_priv, primary_if);
batadv_bla_update_orig_address(bat_priv, primary_if, oldif); batadv_bla_update_orig_address(bat_priv, primary_if, oldif);
out: out:
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
} }
...@@ -481,7 +479,6 @@ static void batadv_primary_if_select(struct batadv_priv *bat_priv, ...@@ -481,7 +479,6 @@ static void batadv_primary_if_select(struct batadv_priv *bat_priv,
batadv_primary_if_update_addr(bat_priv, curr_hard_iface); batadv_primary_if_update_addr(bat_priv, curr_hard_iface);
out: out:
if (curr_hard_iface)
batadv_hardif_put(curr_hard_iface); batadv_hardif_put(curr_hard_iface);
} }
...@@ -657,7 +654,6 @@ batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface) ...@@ -657,7 +654,6 @@ batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface)
bat_priv->algo_ops->iface.activate(hard_iface); bat_priv->algo_ops->iface.activate(hard_iface);
out: out:
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
} }
...@@ -811,7 +807,6 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface) ...@@ -811,7 +807,6 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface)
new_if = batadv_hardif_get_active(hard_iface->soft_iface); new_if = batadv_hardif_get_active(hard_iface->soft_iface);
batadv_primary_if_select(bat_priv, new_if); batadv_primary_if_select(bat_priv, new_if);
if (new_if)
batadv_hardif_put(new_if); batadv_hardif_put(new_if);
} }
...@@ -834,7 +829,6 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface) ...@@ -834,7 +829,6 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface)
batadv_hardif_put(hard_iface); batadv_hardif_put(hard_iface);
out: out:
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
} }
...@@ -990,7 +984,6 @@ static int batadv_hard_if_event(struct notifier_block *this, ...@@ -990,7 +984,6 @@ static int batadv_hard_if_event(struct notifier_block *this,
hardif_put: hardif_put:
batadv_hardif_put(hard_iface); batadv_hardif_put(hard_iface);
out: out:
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
return NOTIFY_DONE; return NOTIFY_DONE;
} }
......
...@@ -2241,7 +2241,7 @@ batadv_mcast_netlink_get_primary(struct netlink_callback *cb, ...@@ -2241,7 +2241,7 @@ batadv_mcast_netlink_get_primary(struct netlink_callback *cb,
if (!ret && primary_if) if (!ret && primary_if)
*primary_if = hard_iface; *primary_if = hard_iface;
else if (hard_iface) else
batadv_hardif_put(hard_iface); batadv_hardif_put(hard_iface);
return ret; return ret;
......
...@@ -359,14 +359,12 @@ static int batadv_netlink_mesh_fill(struct sk_buff *msg, ...@@ -359,14 +359,12 @@ static int batadv_netlink_mesh_fill(struct sk_buff *msg,
atomic_read(&bat_priv->orig_interval))) atomic_read(&bat_priv->orig_interval)))
goto nla_put_failure; goto nla_put_failure;
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
genlmsg_end(msg, hdr); genlmsg_end(msg, hdr);
return 0; return 0;
nla_put_failure: nla_put_failure:
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
genlmsg_cancel(msg, hdr); genlmsg_cancel(msg, hdr);
......
...@@ -936,9 +936,7 @@ void batadv_nc_update_nc_node(struct batadv_priv *bat_priv, ...@@ -936,9 +936,7 @@ void batadv_nc_update_nc_node(struct batadv_priv *bat_priv,
out_nc_node->last_seen = jiffies; out_nc_node->last_seen = jiffies;
out: out:
if (in_nc_node)
batadv_nc_node_put(in_nc_node); batadv_nc_node_put(in_nc_node);
if (out_nc_node)
batadv_nc_node_put(out_nc_node); batadv_nc_node_put(out_nc_node);
} }
...@@ -1215,13 +1213,9 @@ static bool batadv_nc_code_packets(struct batadv_priv *bat_priv, ...@@ -1215,13 +1213,9 @@ static bool batadv_nc_code_packets(struct batadv_priv *bat_priv,
batadv_send_unicast_skb(skb_dest, first_dest); batadv_send_unicast_skb(skb_dest, first_dest);
res = true; res = true;
out: out:
if (router_neigh)
batadv_neigh_node_put(router_neigh); batadv_neigh_node_put(router_neigh);
if (router_coding)
batadv_neigh_node_put(router_coding); batadv_neigh_node_put(router_coding);
if (router_neigh_ifinfo)
batadv_neigh_ifinfo_put(router_neigh_ifinfo); batadv_neigh_ifinfo_put(router_neigh_ifinfo);
if (router_coding_ifinfo)
batadv_neigh_ifinfo_put(router_coding_ifinfo); batadv_neigh_ifinfo_put(router_coding_ifinfo);
return res; return res;
} }
......
...@@ -664,7 +664,6 @@ batadv_neigh_node_create(struct batadv_orig_node *orig_node, ...@@ -664,7 +664,6 @@ batadv_neigh_node_create(struct batadv_orig_node *orig_node,
out: out:
spin_unlock_bh(&orig_node->neigh_list_lock); spin_unlock_bh(&orig_node->neigh_list_lock);
if (hardif_neigh)
batadv_hardif_neigh_put(hardif_neigh); batadv_hardif_neigh_put(hardif_neigh);
return neigh_node; return neigh_node;
} }
...@@ -757,10 +756,8 @@ int batadv_hardif_neigh_dump(struct sk_buff *msg, struct netlink_callback *cb) ...@@ -757,10 +756,8 @@ int batadv_hardif_neigh_dump(struct sk_buff *msg, struct netlink_callback *cb)
ret = msg->len; ret = msg->len;
out: out:
if (hardif)
batadv_hardif_put(hardif); batadv_hardif_put(hardif);
dev_put(hard_iface); dev_put(hard_iface);
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
dev_put(soft_iface); dev_put(soft_iface);
...@@ -784,7 +781,6 @@ void batadv_orig_ifinfo_release(struct kref *ref) ...@@ -784,7 +781,6 @@ void batadv_orig_ifinfo_release(struct kref *ref)
/* this is the last reference to this object */ /* this is the last reference to this object */
router = rcu_dereference_protected(orig_ifinfo->router, true); router = rcu_dereference_protected(orig_ifinfo->router, true);
if (router)
batadv_neigh_node_put(router); batadv_neigh_node_put(router);
kfree_rcu(orig_ifinfo, rcu); kfree_rcu(orig_ifinfo, rcu);
...@@ -843,7 +839,6 @@ void batadv_orig_node_release(struct kref *ref) ...@@ -843,7 +839,6 @@ void batadv_orig_node_release(struct kref *ref)
orig_node->last_bonding_candidate = NULL; orig_node->last_bonding_candidate = NULL;
spin_unlock_bh(&orig_node->neigh_list_lock); spin_unlock_bh(&orig_node->neigh_list_lock);
if (last_candidate)
batadv_orig_ifinfo_put(last_candidate); batadv_orig_ifinfo_put(last_candidate);
spin_lock_bh(&orig_node->vlan_list_lock); spin_lock_bh(&orig_node->vlan_list_lock);
...@@ -1151,7 +1146,6 @@ batadv_find_best_neighbor(struct batadv_priv *bat_priv, ...@@ -1151,7 +1146,6 @@ batadv_find_best_neighbor(struct batadv_priv *bat_priv,
if (!kref_get_unless_zero(&neigh->refcount)) if (!kref_get_unless_zero(&neigh->refcount))
continue; continue;
if (best)
batadv_neigh_node_put(best); batadv_neigh_node_put(best);
best = neigh; best = neigh;
...@@ -1197,7 +1191,6 @@ static bool batadv_purge_orig_node(struct batadv_priv *bat_priv, ...@@ -1197,7 +1191,6 @@ static bool batadv_purge_orig_node(struct batadv_priv *bat_priv,
BATADV_IF_DEFAULT); BATADV_IF_DEFAULT);
batadv_update_route(bat_priv, orig_node, BATADV_IF_DEFAULT, batadv_update_route(bat_priv, orig_node, BATADV_IF_DEFAULT,
best_neigh_node); best_neigh_node);
if (best_neigh_node)
batadv_neigh_node_put(best_neigh_node); batadv_neigh_node_put(best_neigh_node);
/* ... then for all other interfaces. */ /* ... then for all other interfaces. */
...@@ -1217,7 +1210,6 @@ static bool batadv_purge_orig_node(struct batadv_priv *bat_priv, ...@@ -1217,7 +1210,6 @@ static bool batadv_purge_orig_node(struct batadv_priv *bat_priv,
hard_iface); hard_iface);
batadv_update_route(bat_priv, orig_node, hard_iface, batadv_update_route(bat_priv, orig_node, hard_iface,
best_neigh_node); best_neigh_node);
if (best_neigh_node)
batadv_neigh_node_put(best_neigh_node); batadv_neigh_node_put(best_neigh_node);
batadv_hardif_put(hard_iface); batadv_hardif_put(hard_iface);
...@@ -1348,10 +1340,8 @@ int batadv_orig_dump(struct sk_buff *msg, struct netlink_callback *cb) ...@@ -1348,10 +1340,8 @@ int batadv_orig_dump(struct sk_buff *msg, struct netlink_callback *cb)
ret = msg->len; ret = msg->len;
out: out:
if (hardif)
batadv_hardif_put(hardif); batadv_hardif_put(hardif);
dev_put(hard_iface); dev_put(hard_iface);
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
dev_put(soft_iface); dev_put(soft_iface);
......
...@@ -101,7 +101,6 @@ static void _batadv_update_route(struct batadv_priv *bat_priv, ...@@ -101,7 +101,6 @@ static void _batadv_update_route(struct batadv_priv *bat_priv,
} }
/* decrease refcount of previous best neighbor */ /* decrease refcount of previous best neighbor */
if (curr_router)
batadv_neigh_node_put(curr_router); batadv_neigh_node_put(curr_router);
} }
...@@ -128,7 +127,6 @@ void batadv_update_route(struct batadv_priv *bat_priv, ...@@ -128,7 +127,6 @@ void batadv_update_route(struct batadv_priv *bat_priv,
_batadv_update_route(bat_priv, orig_node, recv_if, neigh_node); _batadv_update_route(bat_priv, orig_node, recv_if, neigh_node);
out: out:
if (router)
batadv_neigh_node_put(router); batadv_neigh_node_put(router);
} }
...@@ -269,9 +267,7 @@ static int batadv_recv_my_icmp_packet(struct batadv_priv *bat_priv, ...@@ -269,9 +267,7 @@ static int batadv_recv_my_icmp_packet(struct batadv_priv *bat_priv,
goto out; goto out;
} }
out: out:
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
if (orig_node)
batadv_orig_node_put(orig_node); batadv_orig_node_put(orig_node);
kfree_skb(skb); kfree_skb(skb);
...@@ -324,9 +320,7 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv, ...@@ -324,9 +320,7 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv,
skb = NULL; skb = NULL;
out: out:
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
if (orig_node)
batadv_orig_node_put(orig_node); batadv_orig_node_put(orig_node);
kfree_skb(skb); kfree_skb(skb);
...@@ -425,7 +419,6 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, ...@@ -425,7 +419,6 @@ int batadv_recv_icmp_packet(struct sk_buff *skb,
skb = NULL; skb = NULL;
put_orig_node: put_orig_node:
if (orig_node)
batadv_orig_node_put(orig_node); batadv_orig_node_put(orig_node);
free_skb: free_skb:
kfree_skb(skb); kfree_skb(skb);
...@@ -513,7 +506,6 @@ batadv_last_bonding_replace(struct batadv_orig_node *orig_node, ...@@ -513,7 +506,6 @@ batadv_last_bonding_replace(struct batadv_orig_node *orig_node,
orig_node->last_bonding_candidate = new_candidate; orig_node->last_bonding_candidate = new_candidate;
spin_unlock_bh(&orig_node->neigh_list_lock); spin_unlock_bh(&orig_node->neigh_list_lock);
if (old_candidate)
batadv_orig_ifinfo_put(old_candidate); batadv_orig_ifinfo_put(old_candidate);
} }
...@@ -656,7 +648,6 @@ batadv_find_router(struct batadv_priv *bat_priv, ...@@ -656,7 +648,6 @@ batadv_find_router(struct batadv_priv *bat_priv,
batadv_orig_ifinfo_put(next_candidate); batadv_orig_ifinfo_put(next_candidate);
} }
if (last_candidate)
batadv_orig_ifinfo_put(last_candidate); batadv_orig_ifinfo_put(last_candidate);
return router; return router;
...@@ -785,9 +776,7 @@ batadv_reroute_unicast_packet(struct batadv_priv *bat_priv, struct sk_buff *skb, ...@@ -785,9 +776,7 @@ batadv_reroute_unicast_packet(struct batadv_priv *bat_priv, struct sk_buff *skb,
ret = true; ret = true;
out: out:
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
if (orig_node)
batadv_orig_node_put(orig_node); batadv_orig_node_put(orig_node);
return ret; return ret;
...@@ -1031,7 +1020,6 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, ...@@ -1031,7 +1020,6 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
orig_node); orig_node);
rx_success: rx_success:
if (orig_node)
batadv_orig_node_put(orig_node); batadv_orig_node_put(orig_node);
return NET_RX_SUCCESS; return NET_RX_SUCCESS;
...@@ -1279,7 +1267,6 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, ...@@ -1279,7 +1267,6 @@ int batadv_recv_bcast_packet(struct sk_buff *skb,
kfree_skb(skb); kfree_skb(skb);
ret = NET_RX_DROP; ret = NET_RX_DROP;
out: out:
if (orig_node)
batadv_orig_node_put(orig_node); batadv_orig_node_put(orig_node);
return ret; return ret;
} }
...@@ -152,7 +152,6 @@ int batadv_send_unicast_skb(struct sk_buff *skb, ...@@ -152,7 +152,6 @@ int batadv_send_unicast_skb(struct sk_buff *skb,
if (hardif_neigh && ret != NET_XMIT_DROP) if (hardif_neigh && ret != NET_XMIT_DROP)
hardif_neigh->bat_v.last_unicast_tx = jiffies; hardif_neigh->bat_v.last_unicast_tx = jiffies;
if (hardif_neigh)
batadv_hardif_neigh_put(hardif_neigh); batadv_hardif_neigh_put(hardif_neigh);
#endif #endif
...@@ -309,7 +308,6 @@ bool batadv_send_skb_prepare_unicast_4addr(struct batadv_priv *bat_priv, ...@@ -309,7 +308,6 @@ bool batadv_send_skb_prepare_unicast_4addr(struct batadv_priv *bat_priv,
ret = true; ret = true;
out: out:
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
return ret; return ret;
} }
...@@ -425,7 +423,6 @@ int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv, ...@@ -425,7 +423,6 @@ int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv,
ret = batadv_send_skb_unicast(bat_priv, skb, packet_type, ret = batadv_send_skb_unicast(bat_priv, skb, packet_type,
packet_subtype, orig_node, vid); packet_subtype, orig_node, vid);
if (orig_node)
batadv_orig_node_put(orig_node); batadv_orig_node_put(orig_node);
return ret; return ret;
...@@ -452,7 +449,6 @@ int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb, ...@@ -452,7 +449,6 @@ int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb,
ret = batadv_send_skb_unicast(bat_priv, skb, BATADV_UNICAST_4ADDR, ret = batadv_send_skb_unicast(bat_priv, skb, BATADV_UNICAST_4ADDR,
BATADV_P_DATA, orig_node, vid); BATADV_P_DATA, orig_node, vid);
if (orig_node)
batadv_orig_node_put(orig_node); batadv_orig_node_put(orig_node);
return ret; return ret;
...@@ -474,9 +470,7 @@ void batadv_forw_packet_free(struct batadv_forw_packet *forw_packet, ...@@ -474,9 +470,7 @@ void batadv_forw_packet_free(struct batadv_forw_packet *forw_packet,
else else
consume_skb(forw_packet->skb); consume_skb(forw_packet->skb);
if (forw_packet->if_incoming)
batadv_hardif_put(forw_packet->if_incoming); batadv_hardif_put(forw_packet->if_incoming);
if (forw_packet->if_outgoing)
batadv_hardif_put(forw_packet->if_outgoing); batadv_hardif_put(forw_packet->if_outgoing);
if (forw_packet->queue_left) if (forw_packet->queue_left)
atomic_inc(forw_packet->queue_left); atomic_inc(forw_packet->queue_left);
...@@ -867,7 +861,6 @@ static bool batadv_send_no_broadcast(struct batadv_priv *bat_priv, ...@@ -867,7 +861,6 @@ static bool batadv_send_no_broadcast(struct batadv_priv *bat_priv,
ret = batadv_hardif_no_broadcast(if_out, bcast_packet->orig, ret = batadv_hardif_no_broadcast(if_out, bcast_packet->orig,
orig_neigh); orig_neigh);
if (neigh_node)
batadv_hardif_neigh_put(neigh_node); batadv_hardif_neigh_put(neigh_node);
/* ok, may broadcast */ /* ok, may broadcast */
......
...@@ -383,9 +383,7 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb, ...@@ -383,9 +383,7 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb,
dropped_freed: dropped_freed:
batadv_inc_counter(bat_priv, BATADV_CNT_TX_DROPPED); batadv_inc_counter(bat_priv, BATADV_CNT_TX_DROPPED);
end: end:
if (mcast_single_orig)
batadv_orig_node_put(mcast_single_orig); batadv_orig_node_put(mcast_single_orig);
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
...@@ -838,7 +836,6 @@ static int batadv_softif_slave_add(struct net_device *dev, ...@@ -838,7 +836,6 @@ static int batadv_softif_slave_add(struct net_device *dev,
ret = batadv_hardif_enable_interface(hard_iface, dev); ret = batadv_hardif_enable_interface(hard_iface, dev);
out: out:
if (hard_iface)
batadv_hardif_put(hard_iface); batadv_hardif_put(hard_iface);
return ret; return ret;
} }
...@@ -865,7 +862,6 @@ static int batadv_softif_slave_del(struct net_device *dev, ...@@ -865,7 +862,6 @@ static int batadv_softif_slave_del(struct net_device *dev,
ret = 0; ret = 0;
out: out:
if (hard_iface)
batadv_hardif_put(hard_iface); batadv_hardif_put(hard_iface);
return ret; return ret;
} }
......
...@@ -751,11 +751,8 @@ static void batadv_tp_recv_ack(struct batadv_priv *bat_priv, ...@@ -751,11 +751,8 @@ static void batadv_tp_recv_ack(struct batadv_priv *bat_priv,
wake_up(&tp_vars->more_bytes); wake_up(&tp_vars->more_bytes);
out: out:
if (likely(primary_if))
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
if (likely(orig_node))
batadv_orig_node_put(orig_node); batadv_orig_node_put(orig_node);
if (likely(tp_vars))
batadv_tp_vars_put(tp_vars); batadv_tp_vars_put(tp_vars);
} }
...@@ -885,9 +882,7 @@ static int batadv_tp_send(void *arg) ...@@ -885,9 +882,7 @@ static int batadv_tp_send(void *arg)
} }
out: out:
if (likely(primary_if))
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
if (likely(orig_node))
batadv_orig_node_put(orig_node); batadv_orig_node_put(orig_node);
batadv_tp_sender_end(bat_priv, tp_vars); batadv_tp_sender_end(bat_priv, tp_vars);
...@@ -1208,9 +1203,7 @@ static int batadv_tp_send_ack(struct batadv_priv *bat_priv, const u8 *dst, ...@@ -1208,9 +1203,7 @@ static int batadv_tp_send_ack(struct batadv_priv *bat_priv, const u8 *dst,
ret = 0; ret = 0;
out: out:
if (likely(orig_node))
batadv_orig_node_put(orig_node); batadv_orig_node_put(orig_node);
if (likely(primary_if))
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
return ret; return ret;
...@@ -1459,7 +1452,6 @@ static void batadv_tp_recv_msg(struct batadv_priv *bat_priv, ...@@ -1459,7 +1452,6 @@ static void batadv_tp_recv_msg(struct batadv_priv *bat_priv,
batadv_tp_send_ack(bat_priv, icmp->orig, tp_vars->last_recv, batadv_tp_send_ack(bat_priv, icmp->orig, tp_vars->last_recv,
icmp->timestamp, icmp->session, icmp->uid); icmp->timestamp, icmp->session, icmp->uid);
out: out:
if (likely(tp_vars))
batadv_tp_vars_put(tp_vars); batadv_tp_vars_put(tp_vars);
} }
......
...@@ -813,12 +813,9 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr, ...@@ -813,12 +813,9 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,
ret = true; ret = true;
out: out:
if (in_hardif)
batadv_hardif_put(in_hardif); batadv_hardif_put(in_hardif);
dev_put(in_dev); dev_put(in_dev);
if (tt_local)
batadv_tt_local_entry_put(tt_local); batadv_tt_local_entry_put(tt_local);
if (tt_global)
batadv_tt_global_entry_put(tt_global); batadv_tt_global_entry_put(tt_global);
return ret; return ret;
} }
...@@ -1209,7 +1206,6 @@ int batadv_tt_local_dump(struct sk_buff *msg, struct netlink_callback *cb) ...@@ -1209,7 +1206,6 @@ int batadv_tt_local_dump(struct sk_buff *msg, struct netlink_callback *cb)
ret = msg->len; ret = msg->len;
out: out:
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
dev_put(soft_iface); dev_put(soft_iface);
...@@ -1298,7 +1294,6 @@ u16 batadv_tt_local_remove(struct batadv_priv *bat_priv, const u8 *addr, ...@@ -1298,7 +1294,6 @@ u16 batadv_tt_local_remove(struct batadv_priv *bat_priv, const u8 *addr,
batadv_tt_local_entry_put(tt_removed_entry); batadv_tt_local_entry_put(tt_removed_entry);
out: out:
if (tt_local_entry)
batadv_tt_local_entry_put(tt_local_entry); batadv_tt_local_entry_put(tt_local_entry);
return curr_flags; return curr_flags;
...@@ -1569,7 +1564,6 @@ batadv_tt_global_orig_entry_add(struct batadv_tt_global_entry *tt_global, ...@@ -1569,7 +1564,6 @@ batadv_tt_global_orig_entry_add(struct batadv_tt_global_entry *tt_global,
sync_flags: sync_flags:
batadv_tt_global_sync_flags(tt_global); batadv_tt_global_sync_flags(tt_global);
out: out:
if (orig_entry)
batadv_tt_orig_list_entry_put(orig_entry); batadv_tt_orig_list_entry_put(orig_entry);
spin_unlock_bh(&tt_global->list_lock); spin_unlock_bh(&tt_global->list_lock);
...@@ -1743,9 +1737,7 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv, ...@@ -1743,9 +1737,7 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
tt_global_entry->common.flags &= ~BATADV_TT_CLIENT_ROAM; tt_global_entry->common.flags &= ~BATADV_TT_CLIENT_ROAM;
out: out:
if (tt_global_entry)
batadv_tt_global_entry_put(tt_global_entry); batadv_tt_global_entry_put(tt_global_entry);
if (tt_local_entry)
batadv_tt_local_entry_put(tt_local_entry); batadv_tt_local_entry_put(tt_local_entry);
return ret; return ret;
} }
...@@ -1782,14 +1774,12 @@ batadv_transtable_best_orig(struct batadv_priv *bat_priv, ...@@ -1782,14 +1774,12 @@ batadv_transtable_best_orig(struct batadv_priv *bat_priv,
} }
/* release the refcount for the "old" best */ /* release the refcount for the "old" best */
if (best_router)
batadv_neigh_node_put(best_router); batadv_neigh_node_put(best_router);
best_entry = orig_entry; best_entry = orig_entry;
best_router = router; best_router = router;
} }
if (best_router)
batadv_neigh_node_put(best_router); batadv_neigh_node_put(best_router);
return best_entry; return best_entry;
...@@ -1996,7 +1986,6 @@ int batadv_tt_global_dump(struct sk_buff *msg, struct netlink_callback *cb) ...@@ -1996,7 +1986,6 @@ int batadv_tt_global_dump(struct sk_buff *msg, struct netlink_callback *cb)
ret = msg->len; ret = msg->len;
out: out:
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
dev_put(soft_iface); dev_put(soft_iface);
...@@ -2188,9 +2177,7 @@ static void batadv_tt_global_del(struct batadv_priv *bat_priv, ...@@ -2188,9 +2177,7 @@ static void batadv_tt_global_del(struct batadv_priv *bat_priv,
} }
out: out:
if (tt_global_entry)
batadv_tt_global_entry_put(tt_global_entry); batadv_tt_global_entry_put(tt_global_entry);
if (local_entry)
batadv_tt_local_entry_put(local_entry); batadv_tt_local_entry_put(local_entry);
} }
...@@ -2418,9 +2405,7 @@ struct batadv_orig_node *batadv_transtable_search(struct batadv_priv *bat_priv, ...@@ -2418,9 +2405,7 @@ struct batadv_orig_node *batadv_transtable_search(struct batadv_priv *bat_priv,
rcu_read_unlock(); rcu_read_unlock();
out: out:
if (tt_global_entry)
batadv_tt_global_entry_put(tt_global_entry); batadv_tt_global_entry_put(tt_global_entry);
if (tt_local_entry)
batadv_tt_local_entry_put(tt_local_entry); batadv_tt_local_entry_put(tt_local_entry);
return orig_node; return orig_node;
...@@ -2982,7 +2967,6 @@ static bool batadv_send_tt_request(struct batadv_priv *bat_priv, ...@@ -2982,7 +2967,6 @@ static bool batadv_send_tt_request(struct batadv_priv *bat_priv,
ret = true; ret = true;
out: out:
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
if (ret && tt_req_node) { if (ret && tt_req_node) {
...@@ -2994,7 +2978,6 @@ static bool batadv_send_tt_request(struct batadv_priv *bat_priv, ...@@ -2994,7 +2978,6 @@ static bool batadv_send_tt_request(struct batadv_priv *bat_priv,
spin_unlock_bh(&bat_priv->tt.req_list_lock); spin_unlock_bh(&bat_priv->tt.req_list_lock);
} }
if (tt_req_node)
batadv_tt_req_node_put(tt_req_node); batadv_tt_req_node_put(tt_req_node);
kfree(tvlv_tt_data); kfree(tvlv_tt_data);
...@@ -3126,9 +3109,7 @@ static bool batadv_send_other_tt_response(struct batadv_priv *bat_priv, ...@@ -3126,9 +3109,7 @@ static bool batadv_send_other_tt_response(struct batadv_priv *bat_priv,
spin_unlock_bh(&req_dst_orig_node->tt_buff_lock); spin_unlock_bh(&req_dst_orig_node->tt_buff_lock);
out: out:
if (res_dst_orig_node)
batadv_orig_node_put(res_dst_orig_node); batadv_orig_node_put(res_dst_orig_node);
if (req_dst_orig_node)
batadv_orig_node_put(req_dst_orig_node); batadv_orig_node_put(req_dst_orig_node);
kfree(tvlv_tt_data); kfree(tvlv_tt_data);
return ret; return ret;
...@@ -3243,9 +3224,7 @@ static bool batadv_send_my_tt_response(struct batadv_priv *bat_priv, ...@@ -3243,9 +3224,7 @@ static bool batadv_send_my_tt_response(struct batadv_priv *bat_priv,
spin_unlock_bh(&bat_priv->tt.last_changeset_lock); spin_unlock_bh(&bat_priv->tt.last_changeset_lock);
out: out:
spin_unlock_bh(&bat_priv->tt.commit_lock); spin_unlock_bh(&bat_priv->tt.commit_lock);
if (orig_node)
batadv_orig_node_put(orig_node); batadv_orig_node_put(orig_node);
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
kfree(tvlv_tt_data); kfree(tvlv_tt_data);
/* The packet was for this host, so it doesn't need to be re-routed */ /* The packet was for this host, so it doesn't need to be re-routed */
...@@ -3331,7 +3310,6 @@ static void batadv_tt_fill_gtable(struct batadv_priv *bat_priv, ...@@ -3331,7 +3310,6 @@ static void batadv_tt_fill_gtable(struct batadv_priv *bat_priv,
atomic_set(&orig_node->last_ttvn, ttvn); atomic_set(&orig_node->last_ttvn, ttvn);
out: out:
if (orig_node)
batadv_orig_node_put(orig_node); batadv_orig_node_put(orig_node);
} }
...@@ -3373,7 +3351,6 @@ bool batadv_is_my_client(struct batadv_priv *bat_priv, const u8 *addr, ...@@ -3373,7 +3351,6 @@ bool batadv_is_my_client(struct batadv_priv *bat_priv, const u8 *addr,
goto out; goto out;
ret = true; ret = true;
out: out:
if (tt_local_entry)
batadv_tt_local_entry_put(tt_local_entry); batadv_tt_local_entry_put(tt_local_entry);
return ret; return ret;
} }
...@@ -3437,7 +3414,6 @@ static void batadv_handle_tt_response(struct batadv_priv *bat_priv, ...@@ -3437,7 +3414,6 @@ static void batadv_handle_tt_response(struct batadv_priv *bat_priv,
spin_unlock_bh(&bat_priv->tt.req_list_lock); spin_unlock_bh(&bat_priv->tt.req_list_lock);
out: out:
if (orig_node)
batadv_orig_node_put(orig_node); batadv_orig_node_put(orig_node);
} }
...@@ -3569,7 +3545,6 @@ static void batadv_send_roam_adv(struct batadv_priv *bat_priv, u8 *client, ...@@ -3569,7 +3545,6 @@ static void batadv_send_roam_adv(struct batadv_priv *bat_priv, u8 *client,
&tvlv_roam, sizeof(tvlv_roam)); &tvlv_roam, sizeof(tvlv_roam));
out: out:
if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
} }
...@@ -4165,7 +4140,6 @@ static int batadv_roam_tvlv_unicast_handler_v1(struct batadv_priv *bat_priv, ...@@ -4165,7 +4140,6 @@ static int batadv_roam_tvlv_unicast_handler_v1(struct batadv_priv *bat_priv,
atomic_read(&orig_node->last_ttvn) + 1); atomic_read(&orig_node->last_ttvn) + 1);
out: out:
if (orig_node)
batadv_orig_node_put(orig_node); batadv_orig_node_put(orig_node);
return NET_RX_SUCCESS; return NET_RX_SUCCESS;
} }
......
...@@ -444,7 +444,6 @@ int batadv_tvlv_containers_process(struct batadv_priv *bat_priv, ...@@ -444,7 +444,6 @@ int batadv_tvlv_containers_process(struct batadv_priv *bat_priv,
ogm_source, orig_node, ogm_source, orig_node,
src, dst, tvlv_value, src, dst, tvlv_value,
tvlv_value_cont_len); tvlv_value_cont_len);
if (tvlv_handler)
batadv_tvlv_handler_put(tvlv_handler); batadv_tvlv_handler_put(tvlv_handler);
tvlv_value = (u8 *)tvlv_value + tvlv_value_cont_len; tvlv_value = (u8 *)tvlv_value + tvlv_value_cont_len;
tvlv_value_len -= tvlv_value_cont_len; tvlv_value_len -= tvlv_value_cont_len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment