Skip to contentSkip to conversation

d80211: fix incorrect hw.priv setting in ieee80211_alloc_hw()

PATCH In review Pavel Roskin 2 participants 6 messages Feb 17, 2007 – Feb 19, 2007 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 d80211: fix incorrect hw.priv setting in ieee80211_alloc_hw()

hw.priv is set twice, and the second time it's set incorrectly to an area relative to the master device, which wasn't allocated for private data.

---

 net/d80211/ieee80211.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
net/d80211/ieee80211.c +0 -3
index 456beb3..4f77e27 100644
@@ -4550,9 +4550,6 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
 	mdev->ieee80211_ptr = &sdata->wdev;
 	sdata->wdev.wiphy = wiphy;
 
-	local->hw.priv = (char *)mdev->priv +
-			 ((sizeof(struct ieee80211_sub_if_data) +
-			   NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST);
 	local->hw.queues = 1; /* default */
 
 	local->mdev = mdev;
Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · Pavel Roskin

hw.priv is set twice, and the second time it's set incorrectly to an area relative to the master device, which wasn't allocated for private data.

Yeah, this is obviously correct. Guess I was drinking when I did these patches. I really wonder why I never saw any of your problems though, I do have bcm43xx running here. Not that the driver actually does anything for me, it always refuses to associate...

Quoted 26 lines

---

 net/d80211/ieee80211.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
net/d80211/ieee80211.c +0 -4
index 456beb3..4f77e27 100644
@@ -4550,9 +4550,6 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
 	mdev->ieee80211_ptr = &sdata->wdev;
 	sdata->wdev.wiphy = wiphy;
 
-	local->hw.priv = (char *)mdev->priv +
-			 ((sizeof(struct ieee80211_sub_if_data) +
-			   NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST);
 	local->hw.queues = 1; /* default */
 
 	local->mdev = mdev;
 
-

To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 9 lines · Johannes Berg
Quoted 3 lines · Pavel Roskin

hw.priv is set twice, and the second time it's set incorrectly to an area relative to the master device, which wasn't allocated for private data.

Yeah, this is obviously correct. Guess I was drinking when I did these patches. I really wonder why I never saw any of your problems though, I do have bcm43xx running here. Not that the driver actually does anything for me, it always refuses to associate...

Oh, and by the way, wouldn't it be reasonable to have an inline function to calculate the pointer to the priv area instead of having an actual field for the pointer?

Also, it looks like we need a generic macro for aligning sizes.

Signature · 2 lines
Regards,
Pavel Roskin
#3 lore raw
Quoted 6 lines · Pavel Roskin
Quoted 5 lines · Johannes Berg
Quoted 3 lines · Pavel Roskin

hw.priv is set twice, and the second time it's set incorrectly to an area relative to the master device, which wasn't allocated for private data.

Quoted 8 lines
Quoted 4 lines

Yeah, this is obviously correct. Guess I was drinking when I did these patches. I really wonder why I never saw any of your problems though, I do have bcm43xx running here. Not that the driver actually does anything for me, it always refuses to associate...

Oh, and by the way, wouldn't it be reasonable to have an inline function to calculate the pointer to the priv area instead of having an actual field for the pointer?

Yeah, I guess that isn't too hard to do. But if you think about what the current code will compile to that's also just an addition based on the struct size that is known at compile time.

Quoted 1 line

Also, it looks like we need a generic macro for aligning sizes.

I hated wrapping my head around it so I just made the padding explicit in the struct ;)

johannes

#4 lore raw
Quoted 8 lines · Johannes Berg
Quoted 3 lines · Pavel Roskin

Oh, and by the way, wouldn't it be reasonable to have an inline function to calculate the pointer to the priv area instead of having an actual field for the pointer?

Yeah, I guess that isn't too hard to do. But if you think about what the current code will compile to that's also just an addition based on the struct size that is known at compile time.

Perhaps you misunderstood my idea. There is an field called priv in struct ieee80211_hw. That field will be written to, no matter how good the compiler is at optimization. And most drivers will access that field by reading from memory.

Having an inline function brings following benefits:

1) Memory access is replaced with adding a constant (marginal speed-up)
2) Removing priv from struct ieee80211_hw (marginal memory saving)
3) priv cannot be written to (marginal safety improvement)

I see that the list doesn't look impressive, but I want to correct possible misunderstanding anyway.

Signature · 2 lines
Regards,
Pavel Roskin
#5 lore raw
Quoted 4 lines · Pavel Roskin

Perhaps you misunderstood my idea. There is an field called priv in struct ieee80211_hw. That field will be written to, no matter how good the compiler is at optimization. And most drivers will access that field by reading from memory.

My mistake. I was thinking of struct wiphy.priv and not ieee80211_hw.priv.

johannes