Skip to content

Commit dec0507

Browse files
author
Antonio Quartulli
committed
batman-adv: Initialize lockdep class keys for hashes
Different hashes have the same class key because they get initialised with the same one. For this reason lockdep can create false warning when they are used recursively. Re-initialise the key for each hash after the invocation to hash_new() to avoid this problem. Signed-off-by: Antonio Quartulli <ordex@autistici.org> Tested-by: Linus Lüssing <linus.luessing@web.de> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
1 parent 8425ec6 commit dec0507

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

‎net/batman-adv/originator.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
#include "soft-interface.h"
3030
#include "bridge_loop_avoidance.h"
3131

32+
/* hash class keys */
33+
static struct lock_class_key batadv_orig_hash_lock_class_key;
34+
3235
static void batadv_purge_orig(struct work_struct *work);
3336

3437
static void batadv_start_purge_timer(struct batadv_priv *bat_priv)
@@ -57,6 +60,9 @@ int batadv_originator_init(struct batadv_priv *bat_priv)
5760
if (!bat_priv->orig_hash)
5861
goto err;
5962

63+
batadv_hash_set_lock_class(bat_priv->orig_hash,
64+
&batadv_orig_hash_lock_class_key);
65+
6066
batadv_start_purge_timer(bat_priv);
6167
return 0;
6268

‎net/batman-adv/translation-table.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929

3030
#include <linux/crc16.h>
3131

32+
/* hash class keys */
33+
static struct lock_class_key batadv_tt_local_hash_lock_class_key;
34+
static struct lock_class_key batadv_tt_global_hash_lock_class_key;
35+
3236
static void batadv_send_roam_adv(struct batadv_priv *bat_priv, uint8_t *client,
3337
struct batadv_orig_node *orig_node);
3438
static void batadv_tt_purge(struct work_struct *work);
@@ -235,6 +239,9 @@ static int batadv_tt_local_init(struct batadv_priv *bat_priv)
235239
if (!bat_priv->tt.local_hash)
236240
return -ENOMEM;
237241

242+
batadv_hash_set_lock_class(bat_priv->tt.local_hash,
243+
&batadv_tt_local_hash_lock_class_key);
244+
238245
return 0;
239246
}
240247

@@ -694,6 +701,9 @@ static int batadv_tt_global_init(struct batadv_priv *bat_priv)
694701
if (!bat_priv->tt.global_hash)
695702
return -ENOMEM;
696703

704+
batadv_hash_set_lock_class(bat_priv->tt.global_hash,
705+
&batadv_tt_global_hash_lock_class_key);
706+
697707
return 0;
698708
}
699709

‎net/batman-adv/vis.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828

2929
#define BATADV_MAX_VIS_PACKET_SIZE 1000
3030

31+
/* hash class keys */
32+
static struct lock_class_key batadv_vis_hash_lock_class_key;
33+
3134
static void batadv_start_vis_timer(struct batadv_priv *bat_priv);
3235

3336
/* free the info */
@@ -852,6 +855,9 @@ int batadv_vis_init(struct batadv_priv *bat_priv)
852855
goto err;
853856
}
854857

858+
batadv_hash_set_lock_class(bat_priv->vis.hash,
859+
&batadv_vis_hash_lock_class_key);
860+
855861
bat_priv->vis.my_info = kmalloc(BATADV_MAX_VIS_PACKET_SIZE, GFP_ATOMIC);
856862
if (!bat_priv->vis.my_info)
857863
goto err;

0 commit comments

Comments
 (0)