From patchwork Fri Apr 15 18:24:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Linus_L=C3=BCssing?= X-Patchwork-Id: 930 Return-Path: Received: from fmmailgate02.web.de (fmmailgate02.web.de [217.72.192.227]) by open-mesh.org (Postfix) with ESMTP id D9FBC1542F5 for ; Fri, 15 Apr 2011 20:24:45 +0200 (CEST) Received: from smtp04.web.de ( [172.20.0.225]) by fmmailgate02.web.de (Postfix) with ESMTP id 350AC19C08813 for ; Fri, 15 Apr 2011 20:24:44 +0200 (CEST) Received: from [77.6.4.66] (helo=localhost) by smtp04.web.de with asmtp (TLSv1:AES128-SHA:128) (WEB.DE 4.110 #2) id 1QAnhD-0006HP-00; Fri, 15 Apr 2011 20:24:43 +0200 From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: b.a.t.m.a.n@lists.open-mesh.org Date: Fri, 15 Apr 2011 20:24:42 +0200 Message-Id: <1302891882-11246-1-git-send-email-linus.luessing@web.de> X-Mailer: git-send-email 1.7.4.1 MIME-Version: 1.0 Sender: linus.luessing@web.de X-Sender: linus.luessing@web.de X-Provags-ID: V01U2FsdGVkX1+1rINVWGxar0Xo91qtY8Wqz8+iAhivbt9cbzBO FSDrREQGWzm0UuVZ8XCknKhjpb4Dna5GkThAgqXNKnDWhSzPWk 3Z+fTBAjXhhX5VaW7wdw== Subject: [B.A.T.M.A.N.] [PATCH] batman-adv: Fix crash on module shutdown with multiple ifaces X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.13 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, 15 Apr 2011 18:24:46 -0000 hardif_remove_interfaces() removes all hard interfaces from the hardif_list before freeing and cleaning up any device. However the clean up procedures in orig_hash_del_if() (hardif_remove_interface()->hardif_disable_interface()-> orig_hash_del_if()) need the other interfaces still to be present in the hardif_list. Otherwise it won't renumber any preceding interfaces, which leads to an unhandled kernel paging request in orig_node_del_if()'s "/* copy second part */" due to wrong hard_if->if_num's. With this commit the interface removal on module shutdown will be down in the same way as removing single interfaces from batman only: One interface will be removed and cleaned at a time. Signed-off-by: Linus Lüssing --- hard-interface.c | 15 ++++----------- 1 files changed, 4 insertions(+), 11 deletions(-) diff --git a/hard-interface.c b/hard-interface.c index b3058e4..f039a3d 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -490,20 +490,13 @@ static void hardif_remove_interface(struct hard_iface *hard_iface) void hardif_remove_interfaces(void) { struct hard_iface *hard_iface, *hard_iface_tmp; - struct list_head if_queue; - INIT_LIST_HEAD(&if_queue); - - spin_lock(&hardif_list_lock); - list_for_each_entry_safe(hard_iface, hard_iface_tmp, - &hardif_list, list) { + rtnl_lock(); + list_for_each_entry_safe(hard_iface, hard_iface_tmp, &hardif_list, list) { + spin_lock(&hardif_list_lock); list_del_rcu(&hard_iface->list); - list_add_tail(&hard_iface->list, &if_queue); - } - spin_unlock(&hardif_list_lock); + spin_unlock(&hardif_list_lock); - rtnl_lock(); - list_for_each_entry_safe(hard_iface, hard_iface_tmp, &if_queue, list) { hardif_remove_interface(hard_iface); } rtnl_unlock();