Skip to contentSkip to conversation

Fix handling of failure to create debugfs directory

PATCH In review Pavel Roskin 3 participants 7 messages Aug 8, 2007 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix handling of failure to create debugfs directory

This can happen if CONFIG_BCM43XX_MAC80211_DEBUG is enabled, but CONFIG_DEBUG_FS is not.

---

 .../wireless/bcm43xx-mac80211/bcm43xx_debugfs.c    |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/net/wireless/bcm43xx-mac80211/bcm43xx_debugfs.c +6 -2
index 9ca4625..aded2b3 100644
@@ -408,7 +408,7 @@ static struct file_operations restart_fops = {
 
 int bcm43xx_debug(struct bcm43xx_wldev *dev, enum bcm43xx_dyndbg feature)
 {
-	return !!(dev->dfsentry->dyn_debug[feature]);
+	return !!(dev->dfsentry && dev->dfsentry->dyn_debug[feature]);
 }
 
 static void bcm43xx_remove_dynamic_debug(struct bcm43xx_wldev *dev)
@@ -472,7 +472,9 @@ void bcm43xx_debugfs_add_device(struct bcm43xx_wldev *dev)
 	snprintf(devdir, sizeof(devdir), "%s", wiphy_name(dev->wl->hw->wiphy));
 	e->subdir = debugfs_create_dir(devdir, fs.root);
 	if (!e->subdir || IS_ERR(e->subdir)) {
-		e->subdir = NULL;
+		bcmerr(dev->wl, "debugfs: cannot create %s directory\n",
+		       devdir);
+		dev->dfsentry = NULL;
 		kfree(log->log);
 		kfree(e);
 		return;
@@ -525,6 +527,8 @@ void bcm43xx_debugfs_log_txstat(struct bcm43xx_wldev *dev,
 	struct bcm43xx_txstatus *cur;
 	int i;
 
+	if (!e)
+		return;
 	log = &e->txstatlog;
 	assert(irqs_disabled());
 	spin_lock(&log->lock);
#1 lore raw
Quoted 6 lines · Pavel Roskin

This can happen if CONFIG_BCM43XX_MAC80211_DEBUG is enabled, but CONFIG_DEBUG_FS is not.

---

With this patch installed, and the DEBUG configuration set as above, I get a kernel panic on an x86_64 SMP system. The reason for the panic scrolled off the screen, but the complete stack dump (hand copied) is as follows:

lock_acquire+0x85/0x31
bcm43xx_mac80211: bcm43xx_debugfs_log_txstat+0x5a/099
_spin_lock+0x25/0x31
bcm43xx_mac80211: bcm43xx_interrupt_tasklet+0x21/0x723
bcm43xx_mac80211: bcm43xx_debugfs_log_txstat+0x5a/0x99
bcm43xx_mac80211: bcm43xx_handle_txstatsus+0x12/0x72
bcm43xx_mac80211: bcm43xx_interrupt_tasklet+0x699/0x723
__lock_acquire+0xca2/0xcf0
bcm43xx_mac80211: bcm43xx_interrupt_handler+0x296/0x723
tasklet_action+0x5e/0xb2
__do_softirq+0x5f/0xe3
call_softirq+0x1c/0x28
do_softirq+0x39/0x9f
irq_exit+0x4e/0x50
do_IRQ+0xba/0xd8
default_idle+0x35/0x51
cpu_idle+0xce/0xf1
start_secondary+0x2e0/0x2f2

Larry

Acked-by
#2 lore raw
Quoted 4 lines · Larry Finger
Quoted 3 lines · Pavel Roskin

This can happen if CONFIG_BCM43XX_MAC80211_DEBUG is enabled, but CONFIG_DEBUG_FS is not.

Quoted 8 lines
Quoted 3 lines

---

With this patch installed, and the DEBUG configuration set as above, I get a kernel panic on an x86_64 SMP system. The reason for the panic scrolled off the screen, but the complete stack dump (hand copied) is as follows:

lock_acquire+0x85/0x31
bcm43xx_mac80211: bcm43xx_debugfs_log_txstat+0x5a/099
_spin_lock+0x25/0x31

Ignore the noise above. I had failed to get the right patch. The crash confirms the problem _without_ the patch. Getting it in properly fixes the problem

Larry

#5 lore raw
In reply to Pavel Roskin
Quoted 5 lines · On Wednesday 08 August 2007 07:17:10 Pavel Roskin wrote:

This can happen if CONFIG_BCM43XX_MAC80211_DEBUG is enabled, but CONFIG_DEBUG_FS is not.

---

Thanks, queued.
Larry, this might also apply to bcm4301.

Quoted 36 lines
 .../wireless/bcm43xx-mac80211/bcm43xx_debugfs.c    |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/net/wireless/bcm43xx-mac80211/bcm43xx_debugfs.c +6 -2
index 9ca4625..aded2b3 100644
@@ -408,7 +408,7 @@ static struct file_operations restart_fops = {
 
 int bcm43xx_debug(struct bcm43xx_wldev *dev, enum bcm43xx_dyndbg feature)
 {
-	return !!(dev->dfsentry->dyn_debug[feature]);
+	return !!(dev->dfsentry && dev->dfsentry->dyn_debug[feature]);
 }
 
 static void bcm43xx_remove_dynamic_debug(struct bcm43xx_wldev *dev)
@@ -472,7 +472,9 @@ void bcm43xx_debugfs_add_device(struct bcm43xx_wldev *dev)
 	snprintf(devdir, sizeof(devdir), "%s", wiphy_name(dev->wl->hw->wiphy));
 	e->subdir = debugfs_create_dir(devdir, fs.root);
 	if (!e->subdir || IS_ERR(e->subdir)) {
-		e->subdir = NULL;
+		bcmerr(dev->wl, "debugfs: cannot create %s directory\n",
+		       devdir);
+		dev->dfsentry = NULL;
 		kfree(log->log);
 		kfree(e);
 		return;
@@ -525,6 +527,8 @@ void bcm43xx_debugfs_log_txstat(struct bcm43xx_wldev *dev,
 	struct bcm43xx_txstatus *cur;
 	int i;
 
+	if (!e)
+		return;
 	log = &e->txstatlog;
 	assert(irqs_disabled());
 	spin_lock(&log->lock);
Signature · 1 line
Greetings Michael.
#4 lore raw
In reply to Larry Finger
Quoted 21 lines · On Wednesday 08 August 2007 07:52:21 Larry Finger wrote:
Quoted 6 lines · Pavel Roskin

This can happen if CONFIG_BCM43XX_MAC80211_DEBUG is enabled, but CONFIG_DEBUG_FS is not.

---

With this patch installed, and the DEBUG configuration set as above, I get a kernel panic on an x86_64 SMP system. The reason for the panic scrolled off the screen, but the complete stack dump (hand copied) is as follows:

lock_acquire+0x85/0x31
bcm43xx_mac80211: bcm43xx_debugfs_log_txstat+0x5a/099
_spin_lock+0x25/0x31
bcm43xx_mac80211: bcm43xx_interrupt_tasklet+0x21/0x723
bcm43xx_mac80211: bcm43xx_debugfs_log_txstat+0x5a/0x99
bcm43xx_mac80211: bcm43xx_handle_txstatsus+0x12/0x72
bcm43xx_mac80211: bcm43xx_interrupt_tasklet+0x699/0x723
__lock_acquire+0xca2/0xcf0
bcm43xx_mac80211: bcm43xx_interrupt_handler+0x296/0x723
tasklet_action+0x5e/0xb2
Quoted 8 lines
__do_softirq+0x5f/0xe3
call_softirq+0x1c/0x28
do_softirq+0x39/0x9f
irq_exit+0x4e/0x50
do_IRQ+0xba/0xd8
default_idle+0x35/0x51
cpu_idle+0xce/0xf1
start_secondary+0x2e0/0x2f2

Ah crap. I missed this. I'll do a patch.
But first some lunch :)

Signature · 1 line
Greetings Michael.
#3 lore raw
In reply to Larry Finger
Quoted 12 lines · On Wednesday 08 August 2007 08:02:29 Larry Finger wrote:
Quoted 11 lines · Larry Finger
Quoted 6 lines · Pavel Roskin

This can happen if CONFIG_BCM43XX_MAC80211_DEBUG is enabled, but CONFIG_DEBUG_FS is not.

---

With this patch installed, and the DEBUG configuration set as above, I get a kernel panic on an x86_64 SMP system. The reason for the panic scrolled off the screen, but the complete stack dump (hand copied) is as follows:

Quoted 8 lines
Quoted 3 lines
lock_acquire+0x85/0x31
bcm43xx_mac80211: bcm43xx_debugfs_log_txstat+0x5a/099
_spin_lock+0x25/0x31

Ignore the noise above. I had failed to get the right patch. The crash confirms the problem _without_ the patch. Getting it in properly fixes the problem

Yeah, I just noticed that, too :)
So, I applied it to my queue and it will soon go upstream.
http://bu3sch.de/patches/wireless-dev/LATEST/patches/

Signature · 1 line
Greetings Michael.
#6 lore raw
In reply to Michael Buesch
Quoted 9 lines · Michael Buesch
Quoted 5 lines · On Wednesday 08 August 2007 07:17:10 Pavel Roskin wrote:

This can happen if CONFIG_BCM43XX_MAC80211_DEBUG is enabled, but CONFIG_DEBUG_FS is not.

---

Thanks, queued.
Larry, this might also apply to bcm4301.

Yes it will. Thanks,

Larry