* [PATCH] rt2x00: Fix SLAB corruption during rmmod
@ 2009-04-01 19:18 Ivo van Doorn
2009-04-17 0:18 ` [stable] " Chris Wright
0 siblings, 1 reply; 5+ messages in thread
From: Ivo van Doorn @ 2009-04-01 19:18 UTC (permalink / raw)
To: stable
Cc: Arnaud Patard, Gertjan van Wingerde, linux-wireless,
John W. Linville
At rmmod stage, the code path is the following one :
rt2x00lib_remove_dev
=C2=A0 -> =C2=A0rt2x00lib_uninitialize()
=C2=A0 =C2=A0 =C2=A0 =C2=A0 -> rt2x00rfkill_unregister()
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-> rfkill_unregister()
=C2=A0 =C2=A0 =C2=A0 =C2=A0 -> rt2x00rfkill_free()
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-> rfkill_free()
The problem is that rfkill_free should not be called after rfkill_regis=
ter
otherwise put_device(&rfkill->dev) will be called 2 times. This patch
fixes this by only calling rt2x00rfkill_free() when rt2x00rfkill_regist=
er()
hasn't been called or has failed.
Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Tested-by: Arnaud Patard <apatard@mandriva.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
---
This patch is for 2.6.29 only. The code in question has completely disa=
ppeared
in 2.6.30 and does not contain this bug.
---
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireles=
s/rt2x00/rt2x00.h
index 39ecf3b..820fdb2 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -687,8 +687,7 @@ struct rt2x00_dev {
*/
#ifdef CONFIG_RT2X00_LIB_RFKILL
unsigned long rfkill_state;
-#define RFKILL_STATE_ALLOCATED 1
-#define RFKILL_STATE_REGISTERED 2
+#define RFKILL_STATE_REGISTERED 1
struct rfkill *rfkill;
struct delayed_work rfkill_work;
#endif /* CONFIG_RT2X00_LIB_RFKILL */
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wire=
less/rt2x00/rt2x00dev.c
index 87c0f2c..e694bb7 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -1105,7 +1105,6 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00=
dev)
* Register extra components.
*/
rt2x00leds_register(rt2x00dev);
- rt2x00rfkill_allocate(rt2x00dev);
rt2x00debug_register(rt2x00dev);
=20
set_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
@@ -1137,7 +1136,6 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x=
00dev)
* Free extra components
*/
rt2x00debug_deregister(rt2x00dev);
- rt2x00rfkill_free(rt2x00dev);
rt2x00leds_unregister(rt2x00dev);
=20
/*
diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wire=
less/rt2x00/rt2x00lib.h
index 86cd26f..49309d4 100644
--- a/drivers/net/wireless/rt2x00/rt2x00lib.h
+++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
@@ -260,8 +260,6 @@ static inline void rt2x00crypto_rx_insert_iv(struct=
sk_buff *skb,
#ifdef CONFIG_RT2X00_LIB_RFKILL
void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev);
void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev);
-void rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev);
-void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev);
#else
static inline void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev)
{
@@ -270,14 +268,6 @@ static inline void rt2x00rfkill_register(struct rt=
2x00_dev *rt2x00dev)
static inline void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00de=
v)
{
}
-
-static inline void rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev)
-{
-}
-
-static inline void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev)
-{
-}
#endif /* CONFIG_RT2X00_LIB_RFKILL */
=20
/*
diff --git a/drivers/net/wireless/rt2x00/rt2x00rfkill.c b/drivers/net/w=
ireless/rt2x00/rt2x00rfkill.c
index 3298cae..08ffc6d 100644
--- a/drivers/net/wireless/rt2x00/rt2x00rfkill.c
+++ b/drivers/net/wireless/rt2x00/rt2x00rfkill.c
@@ -94,14 +94,50 @@ static void rt2x00rfkill_poll(struct work_struct *w=
ork)
&rt2x00dev->rfkill_work, RFKILL_POLL_INTERVAL);
}
=20
+static int rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev)
+{
+ struct device *dev =3D wiphy_dev(rt2x00dev->hw->wiphy);
+
+ rt2x00dev->rfkill =3D rfkill_allocate(dev, RFKILL_TYPE_WLAN);
+ if (!rt2x00dev->rfkill)
+ return -ENOMEM;
+
+ rt2x00dev->rfkill->name =3D rt2x00dev->ops->name;
+ rt2x00dev->rfkill->data =3D rt2x00dev;
+ rt2x00dev->rfkill->toggle_radio =3D rt2x00rfkill_toggle_radio;
+ if (test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags)) {
+ rt2x00dev->rfkill->get_state =3D rt2x00rfkill_get_state;
+ rt2x00dev->rfkill->state =3D
+ rt2x00dev->ops->lib->rfkill_poll(rt2x00dev) ?
+ RFKILL_STATE_SOFT_BLOCKED : RFKILL_STATE_UNBLOCKED;
+ } else {
+ rt2x00dev->rfkill->state =3D RFKILL_STATE_UNBLOCKED;
+ }
+
+ INIT_DELAYED_WORK(&rt2x00dev->rfkill_work, rt2x00rfkill_poll);
+
+ return 0;
+}
+
+static void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev)
+{
+ rfkill_free(rt2x00dev->rfkill);
+ rt2x00dev->rfkill =3D NULL;
+}
+
void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev)
{
- if (!test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state) ||
- test_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state))
+ if (test_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state))
+ return;
+
+ if (rt2x00rfkill_allocate(rt2x00dev)) {
+ ERROR(rt2x00dev, "Failed to allocate rfkill handler.\n");
return;
+ }
=20
if (rfkill_register(rt2x00dev->rfkill)) {
ERROR(rt2x00dev, "Failed to register rfkill handler.\n");
+ rt2x00rfkill_free(rt2x00dev);
return;
}
=20
@@ -117,8 +153,7 @@ void rt2x00rfkill_register(struct rt2x00_dev *rt2x0=
0dev)
=20
void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev)
{
- if (!test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state) ||
- !test_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state))
+ if (!test_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state))
return;
=20
cancel_delayed_work_sync(&rt2x00dev->rfkill_work);
@@ -127,46 +162,3 @@ void rt2x00rfkill_unregister(struct rt2x00_dev *rt=
2x00dev)
=20
__clear_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state);
}
-
-void rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev)
-{
- struct device *dev =3D wiphy_dev(rt2x00dev->hw->wiphy);
-
- if (test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state))
- return;
-
- rt2x00dev->rfkill =3D rfkill_allocate(dev, RFKILL_TYPE_WLAN);
- if (!rt2x00dev->rfkill) {
- ERROR(rt2x00dev, "Failed to allocate rfkill handler.\n");
- return;
- }
-
- __set_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state);
-
- rt2x00dev->rfkill->name =3D rt2x00dev->ops->name;
- rt2x00dev->rfkill->data =3D rt2x00dev;
- rt2x00dev->rfkill->toggle_radio =3D rt2x00rfkill_toggle_radio;
- if (test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags)) {
- rt2x00dev->rfkill->get_state =3D rt2x00rfkill_get_state;
- rt2x00dev->rfkill->state =3D
- rt2x00dev->ops->lib->rfkill_poll(rt2x00dev) ?
- RFKILL_STATE_SOFT_BLOCKED : RFKILL_STATE_UNBLOCKED;
- } else {
- rt2x00dev->rfkill->state =3D RFKILL_STATE_UNBLOCKED;
- }
-
- INIT_DELAYED_WORK(&rt2x00dev->rfkill_work, rt2x00rfkill_poll);
-
- return;
-}
-
-void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev)
-{
- if (!test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state))
- return;
-
- cancel_delayed_work_sync(&rt2x00dev->rfkill_work);
-
- rfkill_free(rt2x00dev->rfkill);
- rt2x00dev->rfkill =3D NULL;
-}
--
To unsubscribe from this list: send the line "unsubscribe linux-wireles=
s" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [stable] [PATCH] rt2x00: Fix SLAB corruption during rmmod
2009-04-01 19:18 [PATCH] rt2x00: Fix SLAB corruption during rmmod Ivo van Doorn
@ 2009-04-17 0:18 ` Chris Wright
2009-04-17 3:13 ` Gertjan van Wingerde
0 siblings, 1 reply; 5+ messages in thread
From: Chris Wright @ 2009-04-17 0:18 UTC (permalink / raw)
To: Ivo van Doorn
Cc: stable, Arnaud Patard, linux-wireless, John W. Linville,
Gertjan van Wingerde
* Ivo van Doorn (ivdoorn@gmail.com) wrote:
> At rmmod stage, the code path is the following one :
>=20
> rt2x00lib_remove_dev
> =A0 -> =A0rt2x00lib_uninitialize()
> =A0 =A0 =A0 =A0 -> rt2x00rfkill_unregister()
> =A0 =A0 =A0 =A0 =A0 =A0 =A0-> rfkill_unregister()
> =A0 =A0 =A0 =A0 -> rt2x00rfkill_free()
> =A0 =A0 =A0 =A0 =A0 =A0 =A0-> rfkill_free()
>=20
> The problem is that rfkill_free should not be called after rfkill_reg=
ister
> otherwise put_device(&rfkill->dev) will be called 2 times. This patch
> fixes this by only calling rt2x00rfkill_free() when rt2x00rfkill_regi=
ster()
> hasn't been called or has failed.
>=20
> Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
> Tested-by: Arnaud Patard <apatard@mandriva.com>
> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Who is the Author of this patch? The Signed-off-by order suggests is
Gertjan.
--
To unsubscribe from this list: send the line "unsubscribe linux-wireles=
s" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [stable] [PATCH] rt2x00: Fix SLAB corruption during rmmod
2009-04-17 0:18 ` [stable] " Chris Wright
@ 2009-04-17 3:13 ` Gertjan van Wingerde
2009-04-17 6:56 ` Ivo Van Doorn
0 siblings, 1 reply; 5+ messages in thread
From: Gertjan van Wingerde @ 2009-04-17 3:13 UTC (permalink / raw)
To: Chris Wright
Cc: Ivo van Doorn, stable, Arnaud Patard, linux-wireless,
John W. Linville
Hi Chris,
On 04/17/09 02:18, Chris Wright wrote:
> * Ivo van Doorn (ivdoorn@gmail.com) wrote:
>> At rmmod stage, the code path is the following one :
>>
>> rt2x00lib_remove_dev
>> -> rt2x00lib_uninitialize()
>> -> rt2x00rfkill_unregister()
>> -> rfkill_unregister()
>> -> rt2x00rfkill_free()
>> -> rfkill_free()
>>
>> The problem is that rfkill_free should not be called after rfkill_register
>> otherwise put_device(&rfkill->dev) will be called 2 times. This patch
>> fixes this by only calling rt2x00rfkill_free() when rt2x00rfkill_register()
>> hasn't been called or has failed.
>>
>> Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
>> Tested-by: Arnaud Patard <apatard@mandriva.com>
>> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
>
> Who is the Author of this patch? The Signed-off-by order suggests is
> Gertjan.
>
Indeed, I have been the author of the patch.
---
Gertjan.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [stable] [PATCH] rt2x00: Fix SLAB corruption during rmmod
2009-04-17 3:13 ` Gertjan van Wingerde
@ 2009-04-17 6:56 ` Ivo Van Doorn
2009-04-17 20:26 ` Chris Wright
0 siblings, 1 reply; 5+ messages in thread
From: Ivo Van Doorn @ 2009-04-17 6:56 UTC (permalink / raw)
To: Chris Wright
Cc: stable, Arnaud Patard, linux-wireless, John W. Linville,
Gertjan van Wingerde
Hi,
> On 04/17/09 02:18, Chris Wright wrote:
>> * Ivo van Doorn (ivdoorn@gmail.com) wrote:
>>> At rmmod stage, the code path is the following one :
>>>
>>> rt2x00lib_remove_dev
>>> =A0 -> =A0rt2x00lib_uninitialize()
>>> =A0 =A0 =A0 =A0 -> rt2x00rfkill_unregister()
>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0-> rfkill_unregister()
>>> =A0 =A0 =A0 =A0 -> rt2x00rfkill_free()
>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0-> rfkill_free()
>>>
>>> The problem is that rfkill_free should not be called after rfkill_r=
egister
>>> otherwise put_device(&rfkill->dev) will be called 2 times. This pat=
ch
>>> fixes this by only calling rt2x00rfkill_free() when rt2x00rfkill_re=
gister()
>>> hasn't been called or has failed.
>>>
>>> Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
>>> Tested-by: Arnaud Patard <apatard@mandriva.com>
>>> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
>>
>> Who is the Author of this patch? =A0The Signed-off-by order suggests=
is
>> Gertjan.
>>
>
>
> Indeed, I have been the author of the patch.
Yeah, Gertjan is indeed the author, I forgot to add
the Fom: line at the top of the patch to make that more clear.
Ivo
--
To unsubscribe from this list: send the line "unsubscribe linux-wireles=
s" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [stable] [PATCH] rt2x00: Fix SLAB corruption during rmmod
2009-04-17 6:56 ` Ivo Van Doorn
@ 2009-04-17 20:26 ` Chris Wright
0 siblings, 0 replies; 5+ messages in thread
From: Chris Wright @ 2009-04-17 20:26 UTC (permalink / raw)
To: Ivo Van Doorn
Cc: Chris Wright, stable, Arnaud Patard, linux-wireless,
John W. Linville, Gertjan van Wingerde
* Ivo Van Doorn (ivdoorn@gmail.com) wrote:
> >> Who is the Author of this patch? =A0The Signed-off-by order sugges=
ts is
> >> Gertjan.
> >
> > Indeed, I have been the author of the patch.
>=20
> Yeah, Gertjan is indeed the author, I forgot to add
> the Fom: line at the top of the patch to make that more clear.
Great, thanks, I'll add that in.
-chris
--
To unsubscribe from this list: send the line "unsubscribe linux-wireles=
s" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-04-17 21:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-01 19:18 [PATCH] rt2x00: Fix SLAB corruption during rmmod Ivo van Doorn
2009-04-17 0:18 ` [stable] " Chris Wright
2009-04-17 3:13 ` Gertjan van Wingerde
2009-04-17 6:56 ` Ivo Van Doorn
2009-04-17 20:26 ` Chris Wright
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).