Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 393b299d authored by Markus Elfring's avatar Markus Elfring Committed by Simon Wunderlich
Browse files

batman-adv: Less function calls in batadv_is_ap_isolated() after error detection



The variables "tt_local_entry" and "tt_global_entry" were eventually
checked again despite of a corresponding null pointer test before.

* Avoid this double check by reordering a function call sequence
  and the better selection of jump targets.

* Omit the initialisation for these variables at the beginning then.

Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
Signed-off-by: default avatarSimon Wunderlich <sw@simonwunderlich.de>
parent 0566df30
Loading
Loading
Loading
Loading
+11 −14
Original line number Original line Diff line number Diff line
@@ -3835,8 +3835,8 @@ void batadv_tt_local_commit_changes(struct batadv_priv *bat_priv)
bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst,
bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst,
			   unsigned short vid)
			   unsigned short vid)
{
{
	struct batadv_tt_local_entry *tt_local_entry = NULL;
	struct batadv_tt_local_entry *tt_local_entry;
	struct batadv_tt_global_entry *tt_global_entry = NULL;
	struct batadv_tt_global_entry *tt_global_entry;
	struct batadv_softif_vlan *vlan;
	struct batadv_softif_vlan *vlan;
	bool ret = false;
	bool ret = false;


@@ -3845,27 +3845,24 @@ bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst,
		return false;
		return false;


	if (!atomic_read(&vlan->ap_isolation))
	if (!atomic_read(&vlan->ap_isolation))
		goto out;
		goto vlan_put;


	tt_local_entry = batadv_tt_local_hash_find(bat_priv, dst, vid);
	tt_local_entry = batadv_tt_local_hash_find(bat_priv, dst, vid);
	if (!tt_local_entry)
	if (!tt_local_entry)
		goto out;
		goto vlan_put;


	tt_global_entry = batadv_tt_global_hash_find(bat_priv, src, vid);
	tt_global_entry = batadv_tt_global_hash_find(bat_priv, src, vid);
	if (!tt_global_entry)
	if (!tt_global_entry)
		goto out;
		goto local_entry_put;

	if (!_batadv_is_ap_isolated(tt_local_entry, tt_global_entry))
		goto out;


	if (_batadv_is_ap_isolated(tt_local_entry, tt_global_entry))
		ret = true;
		ret = true;


out:
	batadv_softif_vlan_put(vlan);
	if (tt_global_entry)
	batadv_tt_global_entry_put(tt_global_entry);
	batadv_tt_global_entry_put(tt_global_entry);
	if (tt_local_entry)
local_entry_put:
	batadv_tt_local_entry_put(tt_local_entry);
	batadv_tt_local_entry_put(tt_local_entry);
vlan_put:
	batadv_softif_vlan_put(vlan);
	return ret;
	return ret;
}
}