[B.A.T.M.A.N.] [PATCH 2/3] batman-adv: Free bla hashes on error in bla_init

Sven Eckelmann
2012-05-04T07:32:31Z

bridge_loop_avoidance.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c
index 8bb274b..9d1cb9b 100644
--- a/bridge_loop_avoidance.c
+++ b/bridge_loop_avoidance.c
@@ -1167,15 +1167,19 @@ int bla_init(struct bat_priv *bat_priv)
return 1;

bat_priv->claim_hash = hash_new(128);
+ if (!bat_priv->claim_hash)
+ return -1;
+
bat_priv->backbone_hash = hash_new(32);
+ if (!bat_priv->backbone_hash) {
+ hash_destroy(bat_priv->claim_hash);
+ return -1;
+ }

hash_set_lock_class(bat_priv->claim_hash, &claim_hash_lock_class_key);
hash_set_lock_class(bat_priv->backbone_hash,
&backbone_hash_lock_class_key);

- if (!bat_priv->claim_hash || !bat_priv->backbone_hash)
- return -1;
-
bat_dbg(DBG_BLA, bat_priv, "bla hashes initialized\n");

bla_start_timer(bat_priv);
--
1.7.10