2010-03-11 15:45:31

by Grazvydas Ignotas

[permalink] [raw]
Subject: [PATCH 4/4] wl1251: fix potential crash

In case debugfs does not init for some reason (or is disabled
on older kernels) driver does not allocate stats.fw_stats
structure, but tries to clear it later and trips on a NULL
pointer:

Unable to handle kernel NULL pointer dereference at virtual address
00000000
PC is at __memzero+0x24/0x80
Backtrace:
[<bf0ddb88>] (wl1251_debugfs_reset+0x0/0x30 [wl1251])
[<bf0d6a2c>] (wl1251_op_stop+0x0/0x12c [wl1251])
[<bf0bc228>] (ieee80211_stop_device+0x0/0x74 [mac80211])
[<bf0b0d10>] (ieee80211_stop+0x0/0x4ac [mac80211])
[<c02deeac>] (dev_close+0x0/0xb4)
[<c02deac0>] (dev_change_flags+0x0/0x184)
[<c031f478>] (devinet_ioctl+0x0/0x704)
[<c0320720>] (inet_ioctl+0x0/0x100)

Add a NULL pointer check to fix this.

Signed-off-by: Grazvydas Ignotas <[email protected]>
---
drivers/net/wireless/wl12xx/wl1251_debugfs.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/wl12xx/wl1251_debugfs.c b/drivers/net/wireless/wl12xx/wl1251_debugfs.c
index 0ccba57..05e4d68 100644
--- a/drivers/net/wireless/wl12xx/wl1251_debugfs.c
+++ b/drivers/net/wireless/wl12xx/wl1251_debugfs.c
@@ -466,7 +466,8 @@ out:

void wl1251_debugfs_reset(struct wl1251 *wl)
{
- memset(wl->stats.fw_stats, 0, sizeof(*wl->stats.fw_stats));
+ if (wl->stats.fw_stats != NULL)
+ memset(wl->stats.fw_stats, 0, sizeof(*wl->stats.fw_stats));
wl->stats.retry_count = 0;
wl->stats.excessive_retries = 0;
}
--
1.6.3.3



2010-03-12 06:37:39

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH 4/4] wl1251: fix potential crash

Grazvydas Ignotas <[email protected]> writes:

> In case debugfs does not init for some reason (or is disabled
> on older kernels) driver does not allocate stats.fw_stats
> structure, but tries to clear it later and trips on a NULL
> pointer:
>
> Unable to handle kernel NULL pointer dereference at virtual address
> 00000000
> PC is at __memzero+0x24/0x80
> Backtrace:
> [<bf0ddb88>] (wl1251_debugfs_reset+0x0/0x30 [wl1251])
> [<bf0d6a2c>] (wl1251_op_stop+0x0/0x12c [wl1251])
> [<bf0bc228>] (ieee80211_stop_device+0x0/0x74 [mac80211])
> [<bf0b0d10>] (ieee80211_stop+0x0/0x4ac [mac80211])
> [<c02deeac>] (dev_close+0x0/0xb4)
> [<c02deac0>] (dev_change_flags+0x0/0x184)
> [<c031f478>] (devinet_ioctl+0x0/0x704)
> [<c0320720>] (inet_ioctl+0x0/0x100)
>
> Add a NULL pointer check to fix this.
>
> Signed-off-by: Grazvydas Ignotas <[email protected]>

Acked-by: Kalle Valo <[email protected]>

Thank you for all the patches.

--
Kalle Valo