From patchwork Fri May 7 19:47:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 152 Return-Path: Received: from londo.lunn.ch (londo.lunn.ch [80.238.139.98]) by open-mesh.net (Postfix) with ESMTP id 761981544CC for ; Fri, 7 May 2010 21:48:47 +0200 (CEST) Received: from lunn by londo.lunn.ch with local (Exim 3.36 #1 (Debian)) id 1OATWJ-0005ZI-00; Fri, 07 May 2010 21:47:35 +0200 From: Andrew Lunn To: greg@kroah.com Date: Fri, 7 May 2010 21:47:06 +0200 Message-Id: <1273261651-21378-2-git-send-email-andrew@lunn.ch> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1273261651-21378-1-git-send-email-andrew@lunn.ch> References: <1273261651-21378-1-git-send-email-andrew@lunn.ch> MIME-Version: 1.0 Sender: Andrew Lunn Cc: Marek Lindner , b.a.t.m.a.n@lists.open-mesh.net Subject: [B.A.T.M.A.N.] [PATCH 01/26] Staging: batman-adv: only modify hna-table on active module X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 May 2010 19:48:47 -0000 From: Linus Lüssing 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 Signed-off-by: Marek Lindner Signed-off-by: Andrew Lunn --- drivers/staging/batman-adv/soft-interface.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/batman-adv/soft-interface.c b/drivers/staging/batman-adv/soft-interface.c index 0e2307f..a42b21f 100644 --- a/drivers/staging/batman-adv/soft-interface.c +++ b/drivers/staging/batman-adv/soft-interface.c @@ -152,9 +152,13 @@ int interface_set_mac_addr(struct net_device *dev, void *p) if (!is_valid_ether_addr(addr->sa_data)) return -EADDRNOTAVAIL; - hna_local_remove(dev->dev_addr, "mac address changed"); + /* only modify hna-table if it has been initialised before */ + if (atomic_read(&module_state) == MODULE_ACTIVE) { + hna_local_remove(dev->dev_addr, "mac address changed"); + hna_local_add(addr->sa_data); + } + memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); - hna_local_add(dev->dev_addr); return 0; }