diff options
author | Sven Eckelmann <sven@narfation.org> | 2012-03-29 06:38:20 -0400 |
---|---|---|
committer | Antonio Quartulli <ordex@autistici.org> | 2012-06-18 12:00:57 -0400 |
commit | 5d52dad27a08d2c8851acb12b041088ec07881dd (patch) | |
tree | f5f05095d17bf618eed08fc79ee969b48937dc59 | |
parent | d2b6cc8e460494251442a877fcbc150faa175b4f (diff) |
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.c | 13 | ||||
-rw-r--r-- | net/batman-adv/hash.c | 9 | ||||
-rw-r--r-- | net/batman-adv/hash.h | 4 |
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: | |||
1127 | bla_start_timer(bat_priv); | 1127 | bla_start_timer(bat_priv); |
1128 | } | 1128 | } |
1129 | 1129 | ||
1130 | /* The hash for claim and backbone hash receive the same key because they | ||
1131 | * are getting initialized by hash_new with the same key. Reinitializing | ||
1132 | * them with to different keys to allow nested locking without generating | ||
1133 | * lockdep warnings | ||
1134 | */ | ||
1135 | static struct lock_class_key claim_hash_lock_class_key; | ||
1136 | static struct lock_class_key backbone_hash_lock_class_key; | ||
1137 | |||
1130 | /* initialize all bla structures */ | 1138 | /* initialize all bla structures */ |
1131 | int bla_init(struct bat_priv *bat_priv) | 1139 | int bla_init(struct bat_priv *bat_priv) |
1132 | { | 1140 | { |
@@ -1164,6 +1172,11 @@ int bla_init(struct bat_priv *bat_priv) | |||
1164 | if (!bat_priv->claim_hash || !bat_priv->backbone_hash) | 1172 | if (!bat_priv->claim_hash || !bat_priv->backbone_hash) |
1165 | return -1; | 1173 | return -1; |
1166 | 1174 | ||
1175 | batadv_hash_set_lock_class(bat_priv->claim_hash, | ||
1176 | &claim_hash_lock_class_key); | ||
1177 | batadv_hash_set_lock_class(bat_priv->backbone_hash, | ||
1178 | &backbone_hash_lock_class_key); | ||
1179 | |||
1167 | bat_dbg(DBG_BLA, bat_priv, "bla hashes initialized\n"); | 1180 | bat_dbg(DBG_BLA, bat_priv, "bla hashes initialized\n"); |
1168 | 1181 | ||
1169 | bla_start_timer(bat_priv); | 1182 | 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: | |||
69 | kfree(hash); | 69 | kfree(hash); |
70 | return NULL; | 70 | return NULL; |
71 | } | 71 | } |
72 | |||
73 | void batadv_hash_set_lock_class(struct hashtable_t *hash, | ||
74 | struct lock_class_key *key) | ||
75 | { | ||
76 | uint32_t i; | ||
77 | |||
78 | for (i = 0; i < hash->size; i++) | ||
79 | lockdep_set_class(&hash->list_locks[i], key); | ||
80 | } | ||
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 { | |||
45 | /* allocates and clears the hash */ | 45 | /* allocates and clears the hash */ |
46 | struct hashtable_t *hash_new(uint32_t size); | 46 | struct hashtable_t *hash_new(uint32_t size); |
47 | 47 | ||
48 | /* set class key for all locks */ | ||
49 | void batadv_hash_set_lock_class(struct hashtable_t *hash, | ||
50 | struct lock_class_key *key); | ||
51 | |||
48 | /* free only the hashtable and the hash itself. */ | 52 | /* free only the hashtable and the hash itself. */ |
49 | void hash_destroy(struct hashtable_t *hash); | 53 | void hash_destroy(struct hashtable_t *hash); |
50 | 54 | ||