Skip to contentSkip to conversation

wifi: rt2x00: check for of_get_mac_address error

PATCH In review Rosen Penev 3 participants 6 messages Apr 27 – Apr 28 Ralink RT2X00 wireless LAN driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: rt2x00: check for of_get_mac_address error

is_valid_ether_addr is already a check of of_get_mac_address, in which case it returns an error if false. Just set a random MAC on all errors except for EPROBE_DEFER.

---
 drivers/net/wireless/ralink/rt2x00/rt2x00dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ralink/rt2x00/rt2x00dev.c +1 -1
index 2d778ea5f1b5..51b836343f07 100644
@@ -991,7 +991,7 @@ int rt2x00lib_set_mac_address(struct rt2x00_dev *rt2x00dev, u8 *eeprom_mac_addr)
 	if (ret == -EPROBE_DEFER)
 		return ret;
 
-	if (!is_valid_ether_addr(eeprom_mac_addr)) {
+	if (ret) {
 		eth_random_addr(eeprom_mac_addr);
 		rt2x00_eeprom_dbg(rt2x00dev, "MAC: %pM\n", eeprom_mac_addr);
 	}
Signature · 1 line
2.54.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Rosen Penev

is_valid_ether_addr is already a check of of_get_mac_address, in which case it returns an error if false. Just set a random MAC on all errors except for EPROBE_DEFER.

Quoted 20 lines
---
 drivers/net/wireless/ralink/rt2x00/rt2x00dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ralink/rt2x00/rt2x00dev.c +1 -1
index 2d778ea5f1b5..51b836343f07 100644
@@ -991,7 +991,7 @@ int rt2x00lib_set_mac_address(struct rt2x00_dev *rt2x00dev, u8 *eeprom_mac_addr)
 	if (ret == -EPROBE_DEFER)
 		return ret;
 
-	if (!is_valid_ether_addr(eeprom_mac_addr)) {
+	if (ret) {
 		eth_random_addr(eeprom_mac_addr);
 		rt2x00_eeprom_dbg(rt2x00dev, "MAC: %pM\n", eeprom_mac_addr);
 	}
Signature · 1 line
2.54.0
#2 lore raw
Quoted 7 lines · Stanislaw Gruszka
Quoted 5 lines · Rosen Penev

is_valid_ether_addr is already a check of of_get_mac_address, in which case it returns an error if false. Just set a random MAC on all errors except for EPROBE_DEFER.

Are you sure? I just randomly checked one caller to see what the *eeprom_mac_addr would contain, and I see

        mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
        rt2x00lib_set_mac_address(rt2x00dev, mac);

so that case assumes it can get it from EEPROM and override with OF, but if OF fails then it would still use the EEPROM address as long as it's valid ...

johannes

#3 lore raw
Quoted 12 lines · Johannes Berg
Quoted 7 lines · Stanislaw Gruszka
Quoted 5 lines · Rosen Penev

is_valid_ether_addr is already a check of of_get_mac_address, in which case it returns an error if false. Just set a random MAC on all errors except for EPROBE_DEFER.

Are you sure? I just randomly checked one caller to see what the *eeprom_mac_addr would contain, and I see

Quoted 6 lines
        mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
        rt2x00lib_set_mac_address(rt2x00dev, mac);

so that case assumes it can get it from EEPROM and override with OF, but if OF fails then it would still use the EEPROM address as long as it's valid ...

You have right, please drop the patch.

BTW, the code should be changed to move getting the address from OF out of _set routine.

Regards
Stanislaw

#4 lore raw
Quoted 17 lines · Stanislaw Gruszka
Quoted 15 lines · Johannes Berg
Quoted 7 lines · Stanislaw Gruszka
Quoted 5 lines · Rosen Penev

is_valid_ether_addr is already a check of of_get_mac_address, in which case it returns an error if false. Just set a random MAC on all errors except for EPROBE_DEFER.

Are you sure? I just randomly checked one caller to see what the *eeprom_mac_addr would contain, and I see

        mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
        rt2x00lib_set_mac_address(rt2x00dev, mac);
Quoted 8 lines
Quoted 3 lines

so that case assumes it can get it from EEPROM and override with OF, but if OF fails then it would still use the EEPROM address as long as it's valid ...

You have right, please drop the patch.

BTW, the code should be changed to move getting the address from OF out of _set routine.

Where should it go?

Quoted 3 lines

Regards
Stanislaw

#5 lore raw
Quoted 22 lines · Rosen Penev
Quoted 21 lines · Stanislaw Gruszka
Quoted 18 lines · Johannes Berg
Quoted 7 lines · Stanislaw Gruszka
Quoted 5 lines · Rosen Penev

is_valid_ether_addr is already a check of of_get_mac_address, in which case it returns an error if false. Just set a random MAC on all errors except for EPROBE_DEFER.

Are you sure? I just randomly checked one caller to see what the *eeprom_mac_addr would contain, and I see

        mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
        rt2x00lib_set_mac_address(rt2x00dev, mac);

so that case assumes it can get it from EEPROM and override with OF, but if OF fails then it would still use the EEPROM address as long as it's valid ...

Quoted 5 lines
Quoted 4 lines

You have right, please drop the patch.

BTW, the code should be changed to move getting the address from OF out of _set routine.

Where should it go?

Never mind, I got confused by "set" word in the rt2x00lib_set_mac_address().

Regards
Stanislaw