linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtl8187: ensure priv->hwaddr is always valid
@ 2007-07-16  0:09 Michael Wu
  2007-07-16  9:34 ` Johannes Berg
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Wu @ 2007-07-16  0:09 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless, Johannes Berg

From: Michael Wu <flamingice@sourmilk.net>

conf->mac_addr is not guaranteed to be set. This ensures priv->hwaddr is
always set to a valid mac address. Thanks to Johannes Berg
<johannes@sipsolutions.net> for finding this problem.

Signed-off-by: Michael Wu <flamingice@sourmilk.net>
---

 drivers/net/wireless/rtl8187_dev.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/rtl8187_dev.c b/drivers/net/wireless/rtl8187_dev.c
index cea8589..e61c6d5 100644
--- a/drivers/net/wireless/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl8187_dev.c
@@ -466,7 +466,7 @@ static int rtl8187_add_interface(struct ieee80211_hw *dev,
 		return -EOPNOTSUPP;
 	}
 
-	priv->hwaddr = conf->mac_addr;
+	priv->hwaddr = conf->mac_addr ? conf->mac_addr : dev->wiphy->perm_addr;
 
 	return 0;
 }


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] rtl8187: ensure priv->hwaddr is always valid
  2007-07-16  0:09 [PATCH] rtl8187: ensure priv->hwaddr is always valid Michael Wu
@ 2007-07-16  9:34 ` Johannes Berg
  2007-07-17 18:25   ` Michael Buesch
  2007-07-18  6:29   ` Michael Wu
  0 siblings, 2 replies; 5+ messages in thread
From: Johannes Berg @ 2007-07-16  9:34 UTC (permalink / raw)
  To: Michael Wu; +Cc: John Linville, linux-wireless

[-- Attachment #1: Type: text/plain, Size: 472 bytes --]

On Sun, 2007-07-15 at 17:09 -0700, Michael Wu wrote:
>  
> -	priv->hwaddr = conf->mac_addr;
> +	priv->hwaddr = conf->mac_addr ? conf->mac_addr : dev->wiphy->perm_addr;

Do you allow monitor mode? If so, this isn't correct unless the hardware
is explicitly told to not do anything (most hw doesn't and we use a zero
mac addr for that). conf->mac_addr is NULL in monitor mode for a reason:
we don't want to have any mac address so we don't ACK packets.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] rtl8187: ensure priv->hwaddr is always valid
  2007-07-16  9:34 ` Johannes Berg
@ 2007-07-17 18:25   ` Michael Buesch
  2007-07-18 10:10     ` Johannes Berg
  2007-07-18  6:29   ` Michael Wu
  1 sibling, 1 reply; 5+ messages in thread
From: Michael Buesch @ 2007-07-17 18:25 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Michael Wu, John Linville, linux-wireless

On Monday 16 July 2007 11:34, Johannes Berg wrote:
> On Sun, 2007-07-15 at 17:09 -0700, Michael Wu wrote:
> >  
> > -	priv->hwaddr = conf->mac_addr;
> > +	priv->hwaddr = conf->mac_addr ? conf->mac_addr : dev->wiphy->perm_addr;
> 
> Do you allow monitor mode? If so, this isn't correct unless the hardware
> is explicitly told to not do anything (most hw doesn't and we use a zero
> mac addr for that). conf->mac_addr is NULL in monitor mode for a reason:
> we don't want to have any mac address so we don't ACK packets.

I'd suggest changing this behaviour in the stack, as this bug will
be made again for new drivers in the future.
What about pointing mac_addr to a 00:00:00:00:00 const static mac address,
instead of passing a NULL pointer?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] rtl8187: ensure priv->hwaddr is always valid
  2007-07-16  9:34 ` Johannes Berg
  2007-07-17 18:25   ` Michael Buesch
@ 2007-07-18  6:29   ` Michael Wu
  1 sibling, 0 replies; 5+ messages in thread
From: Michael Wu @ 2007-07-18  6:29 UTC (permalink / raw)
  To: Johannes Berg; +Cc: John Linville, linux-wireless

[-- Attachment #1: Type: text/plain, Size: 543 bytes --]

On Monday 16 July 2007 02:34, Johannes Berg wrote:
> Do you allow monitor mode? If so, this isn't correct unless the hardware
> is explicitly told to not do anything (most hw doesn't and we use a zero
> mac addr for that). conf->mac_addr is NULL in monitor mode for a reason:
> we don't want to have any mac address so we don't ACK packets.
>
It eliminates a NULL pointer dereference, which is a bit more important than 
accidentally ACKing frames. I do not have time right now to put together a 
fix better than this.

-Michael Wu

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] rtl8187: ensure priv->hwaddr is always valid
  2007-07-17 18:25   ` Michael Buesch
@ 2007-07-18 10:10     ` Johannes Berg
  0 siblings, 0 replies; 5+ messages in thread
From: Johannes Berg @ 2007-07-18 10:10 UTC (permalink / raw)
  To: Michael Buesch; +Cc: Michael Wu, John Linville, linux-wireless

[-- Attachment #1: Type: text/plain, Size: 569 bytes --]

On Tue, 2007-07-17 at 20:25 +0200, Michael Buesch wrote:

> I'd suggest changing this behaviour in the stack, as this bug will
> be made again for new drivers in the future.
> What about pointing mac_addr to a 00:00:00:00:00 const static mac address,
> instead of passing a NULL pointer?

I disagree. Having the if statement in the driver doesn't hurt and
neither does having a static zero mac address, but hardware that does
require special setup instead of a zero mac address would have to do
is_zero_etheraddr() or something to figure it out.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-07-18 10:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-16  0:09 [PATCH] rtl8187: ensure priv->hwaddr is always valid Michael Wu
2007-07-16  9:34 ` Johannes Berg
2007-07-17 18:25   ` Michael Buesch
2007-07-18 10:10     ` Johannes Berg
2007-07-18  6:29   ` Michael Wu

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).