summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Eckelmann2012-03-29 12:38:20 +0200
committerAntonio Quartulli2012-06-18 18:00:57 +0200
commit5d52dad27a08d2c8851acb12b041088ec07881dd (patch)
treef5f05095d17bf618eed08fc79ee969b48937dc59
parentbatman-adv: fix skb->data assignment (diff)
downloadkernel-qcow2-linux-5d52dad27a08d2c8851acb12b041088ec07881dd.tar.gz
kernel-qcow2-linux-5d52dad27a08d2c8851acb12b041088ec07881dd.tar.xz
kernel-qcow2-linux-5d52dad27a08d2c8851acb12b041088ec07881dd.zip
batman-adv: Initialize lockdep class keys for hashes
The hash for claim and backbone hash in the bridge loop avoidance code receive the same key because they are getting initialized by hash_new with the same key. Lockdep will create a backtrace when they are used recursively. This can be avoided by reinitializing the key directly after the hash_new. Signed-off-by: Sven Eckelmann <sven@narfation.org>
-rw-r--r--net/batman-adv/bridge_loop_avoidance.c13
-rw-r--r--net/batman-adv/hash.c9
-rw-r--r--net/batman-adv/hash.h4
3 files changed, 26 insertions, 0 deletions
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index 8bf97515a77d..5c1ac559edbb 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -1127,6 +1127,14 @@ out:
bla_start_timer(bat_priv);
}
+/* The hash for claim and backbone hash receive the same key because they
+ * are getting initialized by hash_new with the same key. Reinitializing
+ * them with to different keys to allow nested locking without generating
+ * lockdep warnings
+ */
+static struct lock_class_key claim_hash_lock_class_key;
+static struct lock_class_key backbone_hash_lock_class_key;
+
/* initialize all bla structures */
int bla_init(struct bat_priv *bat_priv)
{
@@ -1164,6 +1172,11 @@ int bla_init(struct bat_priv *bat_priv)
if (!bat_priv->claim_hash || !bat_priv->backbone_hash)
return -1;
+ batadv_hash_set_lock_class(bat_priv->claim_hash,
+ &claim_hash_lock_class_key);
+ batadv_hash_set_lock_class(bat_priv->backbone_hash,
+ &backbone_hash_lock_class_key);
+
bat_dbg(DBG_BLA, bat_priv, "bla hashes initialized\n");
bla_start_timer(bat_priv);
diff --git a/net/batman-adv/hash.c b/net/batman-adv/hash.c
index 117687bedf25..5b2eabe7c4e0 100644
--- a/net/batman-adv/hash.c
+++ b/net/batman-adv/hash.c
@@ -69,3 +69,12 @@ free_hash:
kfree(hash);
return NULL;
}
+
+void batadv_hash_set_lock_class(struct hashtable_t *hash,
+ struct lock_class_key *key)
+{
+ uint32_t i;
+
+ for (i = 0; i < hash->size; i++)
+ lockdep_set_class(&hash->list_locks[i], key);
+}
diff --git a/net/batman-adv/hash.h b/net/batman-adv/hash.h
index d4bd7862719b..93b3c71aeaf8 100644
--- a/net/batman-adv/hash.h
+++ b/net/batman-adv/hash.h
@@ -45,6 +45,10 @@ struct hashtable_t {
/* allocates and clears the hash */
struct hashtable_t *hash_new(uint32_t size);
+/* set class key for all locks */
+void batadv_hash_set_lock_class(struct hashtable_t *hash,
+ struct lock_class_key *key);
+
/* free only the hashtable and the hash itself. */
void hash_destroy(struct hashtable_t *hash);