Re: [crash] kernel BUG at net/core/dev.c:1328!

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Ingo Molnar
Date: Monday, July 21, 2008 - 12:44 pm

* David Miller <davem@davemloft.net> wrote:


Yes, the fix from Ian below solved the CONFIG_MAC80211_HWSIM=y crash i 
was getting. I have no other pending issues other than a few low-prio 
ne2000 build failures.

Thanks guys,

	Ingo

--------->
commit 2f77dd3a3b5c3a27298fa0a09d8703c09c633fc6
Author: Ian Schram <ischram@telenet.be>
Date:   Mon Jul 21 20:18:25 2008 +0200

    mac80211_hwsim.c: fix: BUG: unable to handle kernel NULL pointer dereference at 0000000000000370
    
    I was looking at this out of interest, but I'm in no way familiar with
    the code.
    
    Looks to me that the error handling code in mac80211_hwsim is awkward.
    Which leads to it calling ieee80211_unregister_hw even when
    ieee80211_register_hw failed.
    
    The function has a for loop where it generates all simulated radios.
    when something fails, the error handling will call mac80211_hwsim_free
    which frees all simulated radios who's pointer isn't zero. However the
    information stored is insufficient to determine whether or not the call
    to ieee80211_register_hw succeeded or not for a specific radio. The
    included patch makes init_mac80211_hwsim clean up the current simulated
    radio, and then calls into mac80211_hwsim_free to clean up all the
    radios that did succeed.
    
    This however doesn't explain why the rate control registration failed..
    build tested this, but had some problems reproducing the original
    problem.
    
    Signed-off-by: Ian Schram <ischram@telenet.be>
    Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 drivers/net/wireless/mac80211_hwsim.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 913dc9f..5816230 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -364,8 +364,7 @@ static void mac80211_hwsim_free(void)
 			struct mac80211_hwsim_data *data;
 			data = hwsim_radios[i]->priv;
 			ieee80211_unregister_hw(hwsim_radios[i]);
-			if (!IS_ERR(data->dev))
-				device_unregister(data->dev);
+			device_unregister(data->dev);
 			ieee80211_free_hw(hwsim_radios[i]);
 		}
 	}
@@ -437,7 +436,7 @@ static int __init init_mac80211_hwsim(void)
 			       "mac80211_hwsim: device_create_drvdata "
 			       "failed (%ld)\n", PTR_ERR(data->dev));
 			err = -ENOMEM;
-			goto failed;
+			goto failed_drvdata;
 		}
 		data->dev->driver = &mac80211_hwsim_driver;
 
@@ -461,7 +460,7 @@ static int __init init_mac80211_hwsim(void)
 		if (err < 0) {
 			printk(KERN_DEBUG "mac80211_hwsim: "
 			       "ieee80211_register_hw failed (%d)\n", err);
-			goto failed;
+			goto failed_hw;
 		}
 
 		printk(KERN_DEBUG "%s: hwaddr %s registered\n",
@@ -479,9 +478,9 @@ static int __init init_mac80211_hwsim(void)
 	rtnl_lock();
 
 	err = dev_alloc_name(hwsim_mon, hwsim_mon->name);
-	if (err < 0) {
+	if (err < 0)
 		goto failed_mon;
-	}
+
 
 	err = register_netdevice(hwsim_mon);
 	if (err < 0)
@@ -494,7 +493,14 @@ static int __init init_mac80211_hwsim(void)
 failed_mon:
 	rtnl_unlock();
 	free_netdev(hwsim_mon);
+	mac80211_hwsim_free();
+	return err;
 
+failed_hw:
+	device_unregister(data->dev);
+failed_drvdata:
+	ieee80211_free_hw(hw);
+	hwsim_radios[i] = 0;
 failed:
 	mac80211_hwsim_free();
 	return err;
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[GIT]: Networking, David Miller, (Sun Jul 20, 10:44 am)
Re: [GIT]: Networking, Arjan van de Ven, (Sun Jul 20, 10:59 am)
Re: [GIT]: Networking, David Miller, (Sun Jul 20, 4:52 pm)
Re: [GIT]: Networking, Linus Torvalds, (Sun Jul 20, 5:54 pm)
Re: [GIT]: Networking, David Miller, (Sun Jul 20, 6:03 pm)
Re: [GIT]: Networking, Linus Torvalds, (Sun Jul 20, 6:07 pm)
Re: [GIT]: Networking, Alexey Dobriyan, (Sun Jul 20, 6:09 pm)
Re: [GIT]: Networking, David Miller, (Sun Jul 20, 6:14 pm)
Re: [GIT]: Networking, David Miller, (Sun Jul 20, 6:17 pm)
Re: [GIT]: Networking, Patrick McHardy, (Sun Jul 20, 6:20 pm)
Re: [GIT]: Networking, Alexey Dobriyan, (Sun Jul 20, 6:22 pm)
Re: [GIT]: Networking, Alexey Dobriyan, (Sun Jul 20, 7:40 pm)
Re: [GIT]: Networking, David Miller, (Sun Jul 20, 7:48 pm)
Re: [GIT]: Networking, David Miller, (Sun Jul 20, 10:11 pm)
Re: [GIT]: Networking, Alexander Beregalov, (Mon Jul 21, 2:48 am)
Re: [GIT]: Networking, Ben Hutchings, (Mon Jul 21, 3:16 am)
Re: [GIT]: Networking, Stefan Richter, (Mon Jul 21, 4:28 am)
Re: [GIT]: Networking, James Morris, (Mon Jul 21, 4:45 am)
Re: [GIT]: Networking, Alexey Dobriyan, (Mon Jul 21, 4:57 am)
Re: [GIT]: Networking, Patrick McHardy, (Mon Jul 21, 5:05 am)
Re: [GIT]: Networking, Ingo Molnar, (Mon Jul 21, 6:50 am)
Re: [GIT]: Networking, Stefan Richter, (Mon Jul 21, 7:15 am)
Re: [GIT]: Networking, David Miller, (Mon Jul 21, 8:27 am)
Re: [GIT]: Networking, David Miller, (Mon Jul 21, 8:35 am)
Re: [GIT]: Networking, Alexander Beregalov, (Mon Jul 21, 9:04 am)
Re: [GIT]: Networking, Linus Torvalds, (Mon Jul 21, 9:49 am)
Re: [GIT]: Networking, David Miller, (Mon Jul 21, 9:53 am)
Re: [GIT]: Networking, David Miller, (Mon Jul 21, 10:28 am)
Re: [GIT]: Networking, Linus Torvalds, (Mon Jul 21, 10:40 am)
[crash] kernel BUG at net/core/dev.c:1328!, Ingo Molnar, (Mon Jul 21, 11:23 am)
Re: [crash] kernel BUG at net/core/dev.c:1328!, Linus Torvalds, (Mon Jul 21, 11:35 am)
Re: [crash] kernel BUG at net/core/dev.c:1328!, Ingo Molnar, (Mon Jul 21, 11:46 am)
Re: [crash] kernel BUG at net/core/dev.c:1328!, David Miller, (Mon Jul 21, 12:00 pm)
Re: [crash] kernel BUG at net/core/dev.c:1328!, Stefan Richter, (Mon Jul 21, 12:20 pm)
Re: [crash] kernel BUG at net/core/dev.c:1328!, Ingo Molnar, (Mon Jul 21, 12:30 pm)
Re: [crash] kernel BUG at net/core/dev.c:1328!, Ingo Molnar, (Mon Jul 21, 12:44 pm)
Re: [crash] kernel BUG at net/core/dev.c:1328!, David Miller, (Mon Jul 21, 1:11 pm)
Re: [crash] kernel BUG at net/core/dev.c:1328!, David Miller, (Mon Jul 21, 1:20 pm)
Re: [GIT]: Networking, David Miller, (Mon Jul 21, 1:32 pm)
Re: [GIT]: Networking, Patrick McHardy, (Mon Jul 21, 1:33 pm)
Re: [crash] kernel BUG at net/core/dev.c:1328!, Stefan Richter, (Mon Jul 21, 2:26 pm)
[TCP bug] stuck distcc connections in latest -git, Ingo Molnar, (Tue Jul 22, 4:21 am)
Re: [TCP bug] stuck distcc connections in latest -git, David Newall, (Tue Jul 22, 6:45 am)
Re: [TCP bug] stuck distcc connections in latest -git, Ingo Molnar, (Tue Jul 22, 6:57 am)
Re: [TCP bug] stuck distcc connections in latest -git, David Newall, (Tue Jul 22, 7:54 am)
Re: [TCP bug] stuck distcc connections in latest -git, Ingo Molnar, (Tue Jul 22, 8:34 am)
Re: [TCP bug] stuck distcc connections in latest -git, Willy Tarreau, (Tue Jul 22, 2:12 pm)
Re: [TCP bug] stuck distcc connections in latest -git, Ingo Molnar, (Wed Jul 23, 1:26 am)
Re: [GIT]: Networking, David Miller, (Wed Jul 23, 4:42 pm)
Re: [regression] nf_iterate(), BUG: unable to handle kerne ..., Krzysztof Oledzki, (Thu Jul 24, 11:00 am)