Changeset 1578

Show
Ignore:
Timestamp:
02/27/10 06:56:18 (5 months ago)
Author:
marek
Message:

batman-adv: only modify hna-table on active module

If we haven't set the module to MODULE_ACTIVE state before (in general,
no interface has yet been added to batman-adv) then the hna table is not
initialised yet. If the kernel changes the mac address of the bat0
interface at this moment then an hna_local_add() called by interface_set_mac_addr()
then resulted in a null pointer derefernce. With this patch we are now
explicitly checking before if the state is MODULE_ACTIVE right now so
that we can assume having an initialised hna table.

Signed-off-by: Linus Lüssing <linus.luessing@…>

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/batman-adv-kernelland/soft-interface.c

    r1551 r1578  
    155155                return -EADDRNOTAVAIL; 
    156156 
    157         hna_local_remove(dev->dev_addr, "mac address changed"); 
     157        /* only modify hna-table if it has been initialised before */ 
     158        if (atomic_read(&module_state) == MODULE_ACTIVE) { 
     159                hna_local_remove(dev->dev_addr, "mac address changed"); 
     160                hna_local_add(addr->sa_data); 
     161        } 
     162 
    158163        memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); 
    159         hna_local_add(dev->dev_addr); 
    160164 
    161165        return 0;