]> Pileus Git - ~andy/linux/blobdiff - net/batman-adv/translation-table.c
rds: use little-endian bitops
[~andy/linux] / net / batman-adv / translation-table.c
index cd8a58396d26b025014f85db919040bc5d34d08c..8d15b48d1692455c7a71c34c8d1031fc426bca14 100644 (file)
@@ -589,17 +589,20 @@ void hna_global_free(struct bat_priv *bat_priv)
 struct orig_node *transtable_search(struct bat_priv *bat_priv, uint8_t *addr)
 {
        struct hna_global_entry *hna_global_entry;
+       struct orig_node *orig_node = NULL;
 
        spin_lock_bh(&bat_priv->hna_ghash_lock);
        hna_global_entry = hna_global_hash_find(bat_priv, addr);
 
-       if (hna_global_entry)
-               kref_get(&hna_global_entry->orig_node->refcount);
+       if (!hna_global_entry)
+               goto out;
 
-       spin_unlock_bh(&bat_priv->hna_ghash_lock);
+       if (!atomic_inc_not_zero(&hna_global_entry->orig_node->refcount))
+               goto out;
 
-       if (!hna_global_entry)
-               return NULL;
+       orig_node = hna_global_entry->orig_node;
 
-       return hna_global_entry->orig_node;
+out:
+       spin_unlock_bh(&bat_priv->hna_ghash_lock);
+       return orig_node;
 }