source: packages/net/batman-advanced/patches/0002-batman-adv-unify-orig_hash_lock-spinlock-handling-to.patch @ 22823

Last change on this file since 22823 was 22823, checked in by marek, 6 years ago

batman-adv: adding stability patches

Signed-off-by: Marek Lindner <lindner_marek@…>

File size: 2.4 KB
  • originator.c

    From 3680f6998508e0a2a22bad3837028d172bb197b1 Mon Sep 17 00:00:00 2001
    From: Marek Lindner <lindner_marek@yahoo.de>
    Date: Sun, 8 Aug 2010 13:01:11 +0000
    Subject: [PATCH 04/10] batman-adv: unify orig_hash_lock spinlock handling to avoid deadlocks
    
    The orig_hash_lock spinlock always has to be locked with IRQs being
    disabled to avoid deadlocks between code that is being executed in
    IRQ context and code that is being executed in non-IRQ context.
    
    Reported-by: Sven Eckelmann <sven.eckelmann@gmx.de>
    Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
    Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
    ---
     originator.c |   14 ++++++++------
     1 files changed, 8 insertions(+), 6 deletions(-)
    
    diff --git a/originator.c b/originator.c
    index 9fa1ac3..068210a 100644
    a b static int orig_node_add_if(struct orig_node *orig_node, int max_if_num) 
    392392int orig_hash_add_if(struct batman_if *batman_if, int max_if_num) 
    393393{ 
    394394        struct orig_node *orig_node; 
     395        unsigned long flags; 
    395396        HASHIT(hashit); 
    396397 
    397398        /* resize all orig nodes because orig_node->bcast_own(_sum) depend on 
    398399         * if_num */ 
    399         spin_lock(&orig_hash_lock); 
     400        spin_lock_irqsave(&orig_hash_lock, flags); 
    400401 
    401402        while (hash_iterate(orig_hash, &hashit)) { 
    402403                orig_node = hashit.bucket->data; 
    int orig_hash_add_if(struct batman_if *batman_if, int max_if_num) 
    405406                        goto err; 
    406407        } 
    407408 
    408         spin_unlock(&orig_hash_lock); 
     409        spin_unlock_irqrestore(&orig_hash_lock, flags); 
    409410        return 0; 
    410411 
    411412err: 
    412         spin_unlock(&orig_hash_lock); 
     413        spin_unlock_irqrestore(&orig_hash_lock, flags); 
    413414        return -ENOMEM; 
    414415} 
    415416 
    int orig_hash_del_if(struct batman_if *batman_if, int max_if_num) 
    469470{ 
    470471        struct batman_if *batman_if_tmp; 
    471472        struct orig_node *orig_node; 
     473        unsigned long flags; 
    472474        HASHIT(hashit); 
    473475        int ret; 
    474476 
    475477        /* resize all orig nodes because orig_node->bcast_own(_sum) depend on 
    476478         * if_num */ 
    477         spin_lock(&orig_hash_lock); 
     479        spin_lock_irqsave(&orig_hash_lock, flags); 
    478480 
    479481        while (hash_iterate(orig_hash, &hashit)) { 
    480482                orig_node = hashit.bucket->data; 
    int orig_hash_del_if(struct batman_if *batman_if, int max_if_num) 
    501503        rcu_read_unlock(); 
    502504 
    503505        batman_if->if_num = -1; 
    504         spin_unlock(&orig_hash_lock); 
     506        spin_unlock_irqrestore(&orig_hash_lock, flags); 
    505507        return 0; 
    506508 
    507509err: 
    508         spin_unlock(&orig_hash_lock); 
     510        spin_unlock_irqrestore(&orig_hash_lock, flags); 
    509511        return -ENOMEM; 
    510512} 
Note: See TracBrowser for help on using the repository browser.